iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >如何在Centos7.4下部署mysql5.7.24
  • 816
分享到

如何在Centos7.4下部署mysql5.7.24

2024-04-02 19:04:59 816人浏览 安东尼
摘要

这篇文章主要介绍“如何在Centos7.4下部署Mysql5.7.24”,在日常操作中,相信很多人在如何在Centos7.4下部署mysql5.7.24问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操

这篇文章主要介绍“如何在Centos7.4下部署Mysql5.7.24”,在日常操作中,相信很多人在如何在Centos7.4下部署mysql5.7.24问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何在Centos7.4下部署mysql5.7.24”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

在安装mysql前需要对服务器的环境做一些配置:

1、主机名解析,/etc/hosts配置;

2、jdk环境变量配置;

3、Mysql5.7.24的安装;

一、环境

操作系统:Centos7.4

Mysql数据库:mysql-5.7.24-el7-x86_64.tar

JDK:jdk-8u131-linux-x64.tar.gz

首先需要将Mysql软件和JDK都上传到服务器上。

1、配置主机名解析

vi /etc/hosts

主机名    IP地址

例如:

主机名    IP地址

test        192.168.1.10

2、JDK环境配置

通常我将软件解压后放在/usr/java目录下,java文件夹需要自己创建:

mkdir /usr/java

然后解压 jdk-8u131-linux-x64.tar.gz 到 /usr/java目录

tar -xzf jdk-8u131-linux-x64.tar.gz -C /usr/java

设置环境变量/etc/profile文件里:

vi /etc/profile

按 i 键进入编辑模式。

在 /etc/profile 文件中添加以下信息:

export JAVA_HOME=/usr/java/jdk1.8.0_131

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH

export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin

export PATH=$PATH:${JAVA_PATH}

按 Esc 键退出编辑模式,输入 :wq 保存并关闭文件。

加载环境变量使之生效:source /etc/profile

查看 jdk 版本。当出现 jdk 版本信息时,表示 JDK 已经安装成功。

#java -version

java version "1.8.0_141"

Java(TM) SE Runtime Environment (build 1.8.0_141-b15)

Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)

二、安装mysql

1、在安装mysql前,创建mysql用户

groupadd mysql

useradd -g mysql mysql

2、然后解压缩mysql-5.7.24-el7-x86_64.tar,会生成mysql-5.7.24-el7-x86_64文件夹,使用mv命令将其名字改为mysql,并放到/usr/local/目录下。

mv mysql-5.7.24-el7-x86_64 /usr/local/mysql

3、建立data目录,进入到/usr/local/mysql/目录,创建data目录

mkdir  data

4、修改mysql属主

使用chown命令mysql的属主,进入/usr/local目录,执行下面命令

chown -R mysql:mysql mysql

5、对mysql进行初始化

首先进入/usr/local/mysql/bin目录,执行下面语句

./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

执行完毕后如下:

[root@YQHDB2 bin]# ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

2019-02-01T08:56:56.506838Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2019-02-01T08:56:56.856781Z 0 [Warning] InnoDB: New log files created, LSN=45790

2019-02-01T08:56:56.913915Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2019-02-01T08:56:56.973956Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 541f5848-25ff-11e9-800d-000c297c0daa.

2019-02-01T08:56:56.975026Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2019-02-01T08:56:56.976563Z 1 [Note] A temporary passWord is generated for root@localhost: fhDQ&DYMn7IW

最后一行的冒号之后,是自动生成的登陆密码,一定要记住,后面会登陆数据库进行修改密码;
6、从support-files目录复制mysql.server文件到/etc/init.d/目录,并改名为mysqld,尝试启动mysqld服务

进入/usr/local/mysql/support-files目录,cp mysql.server /etc/init.d/mysqld,然后使用下面命令启动mysqld服务:

service mysqld start

7、修改数据库密码

登陆数据库修改密码:

./mysql -u root -p

输入上面初始化时给的密码,使用set password=password('你的密码')进行修改,修改完后,可使用新密码进行登陆。

部署过程中遇到的问题处理:

1、如果想再次初始化,需要将data文件夹里的内容使用rm -rf * 命令全部删除,然后再初始化;

2、mysqld文件里包含了软件安装目录和数据目录,这里软件目录为basedir=/usr/local/mysql ,数据目录为datadir=/usr/local/mysql/data,可以根据自己的喜好进行调整;

3、所有的错误信息保存在data目录下,以err为后缀的文件里;

4、[ERROR] Could not create unix Socket lock file /var/lib/mysql/mysql.sock.lock.

[ERROR] Unable to setup unix socket lock file.

需要将/var/lib/目录下的mysql的属主改为mysql,如果没有mysql目录需要创建

5、关于my.cnf文件在5.7里没有,这里给大家提供一个比较原始的,为5.5环境下的,具体内容如下:

vi /etc/my.cnf

[root@YQHDB2 support-files]# vi /etc/my.cnf 

# Example MySQL config file for medium systems.

#

# This is for a system with little memory (32M - 64M) where MySQL plays

# an important part, or systems up to 128M where MySQL is used together with

# other programs (such as a WEB server)

#

# MySQL programs look for option files in a set of

# locations which depend on the deployment platfORM.

# You can copy this option file to one of those

# locations. For information about these locations, see:

# Http://dev.mysql.com/doc/mysql/en/option-files.html

#

# In this file, you can use all long options that a program supports.

# If you want to know which options a program supports, run the program

# with the "--help" option.

# The following options will be passed to all MySQL clients

[client]

#password       = your_password

port            = 3306

socket          = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL Server

[mysqld]

port            = 3306

socket          = /var/lib/mysql/mysql.sock

skip-external-locking

key_buffer_size = 16M

max_allowed_packet = 1M

table_open_cache = 64

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

# Don't listen on a tcp/IP port at all. This can be a security enhancement,

# if all processes that need to connect to mysqld run on the same host.

# All interaction with mysqld must be made via Unix sockets or named pipes.

# Note that using this option without enabling named pipes on windows

# (via the "enable-named-pipe" option) will render mysqld useless!

#

#skip-networking

# Replication Master Server (default)

# binary logging is required for replication

log-bin=mysql-bin

# binary logging format - mixed recommended

binlog_format=mixed

# required unique id between 1 and 2^32 - 1

# defaults to 1 if master-host is not set

# but will not function as a master if omitted

server-id       = 1

# Replication Slave (comment out master section to use this)

#

# To configure this host as a replication slave, you can choose between

# two methods :

#

# 1) Use the CHANGE MASTER TO command (fully described in our manual) -

#    the syntax is:

#

#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,

#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;

#

#    where you replace <host>, <user>, <password> by quoted strings and

#    <port> by the master's port number (3306 by default).

#

#    Example:

#

#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,

#    MASTER_USER='joe', MASTER_PASSWORD='secret';

#

# OR

#

# 2) Set the variables below. However, in case you choose this method, then

#    start replication for the first time (even unsuccessfully, for example

#    if you mistyped the password in master-password and the slave fails to

#    connect), the slave will create a master.info file, and any later

#    change in this file to the variables' values below will be ignored and

#    overridden by the content of the master.info file, unless you shutdown

#    the slave server, delete master.info and restart the slaver server.

#    For that reason, you may want to leave the lines below untouched

#    (commented) and instead use CHANGE MASTER TO (see above)

#

# required unique id between 2 and 2^32 - 1

# (and different from the master)

# defaults to 2 if master-host is set

# but will not function as a slave if omitted

#server-id       = 2

#

# The replication master for this slave - required

#master-host     =   <hostname>

#

# The username the slave will use for authentication when connecting

# to the master - required

#master-user     =   <username>

#

# The password the slave will authenticate with when connecting to

# the master - required

#master-password =   <password>

#

# The port the master is listening on.

# optional - defaults to 3306

#master-port     =  <port>

#

# binary logging - not required for slaves, but recommended

#log-bin=mysql-bin

# Uncomment the following if you are using InnoDB tables

#innodb_data_home_dir = /var/lib/mysql

#innodb_data_file_path = ibdata1:10M:autoextend

#innodb_log_group_home_dir = /var/lib/mysql

# You can set .._buffer_pool_size up to 50 - 80 %

# of RAM but beware of setting memory usage too high

#innodb_buffer_pool_size = 16M

#innodb_additional_mem_pool_size = 2M

# Set .._log_file_size to 25 % of buffer pool size

#innodb_log_file_size = 5M

#innodb_log_buffer_size = 8M

#innodb_flush_log_at_trx_commit = 1

#innodb_lock_wait_timeout = 50

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

-----------------------------------------------------------------------------------

只需将上面的内容复制到my.cnf文件即可,具体需要什么参数,可通过网上查找;

到此,关于“如何在Centos7.4下部署mysql5.7.24”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注编程网网站,小编会继续努力为大家带来更多实用的文章!

您可能感兴趣的文档:

--结束END--

本文标题: 如何在Centos7.4下部署mysql5.7.24

本文链接: https://www.lsjlt.com/news/59936.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 如何在Centos7.4下部署mysql5.7.24
    这篇文章主要介绍“如何在Centos7.4下部署mysql5.7.24”,在日常操作中,相信很多人在如何在Centos7.4下部署mysql5.7.24问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操...
    99+
    2024-04-02
  • 如何在linux下部署php项目
    这篇文章主要介绍了如何在linux下部署php项目,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。  linux下部署php项目环境可以分为两种,一种使用Apache,php,...
    99+
    2023-06-15
  • 如何在Linux下安装和部署LXC
    这篇文章主要讲解了“如何在Linux下安装和部署LXC”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“如何在Linux下安装和部署LXC”吧!  LXC 中文名称就是 Linux 容器工具,容...
    99+
    2023-06-13
  • Windows Server 2012下如何安装MYSQL5.7.24
    这篇文章主要介绍了Windows Server 2012下如何安装MYSQL5.7.24,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。1.准备好数据库的....
    99+
    2023-06-29
  • Docker下如何部署lnmp
    小编给大家分享一下Docker下如何部署lnmp,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!拉取一个centos镜像//下载centos镜像[root@loca...
    99+
    2023-06-21
  • Linux下如何部署VPS
    本篇内容主要讲解“Linux下如何部署VPS”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Linux下如何部署VPS”吧!VPS技术,将一台服务器分割成多个虚拟专享服务器的优质服务。实现VPS的...
    99+
    2023-06-27
  • Linux下如何部署Jenkins
    这篇文章主要介绍Linux下如何部署Jenkins,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软...
    99+
    2023-06-27
  • Linux下如何部署Harbor
    这篇文章主要介绍“Linux下如何部署Harbor”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Linux下如何部署Harbor”文章能帮助大家解决问题。Harbor 是为企业用户设计的容器镜像仓库...
    99+
    2023-06-27
  • linux下如何部署kodexplorer
    这篇文章主要介绍linux下如何部署kodexplorer,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!环境为xampp。首先将解压完的目录复制到我们的xampp中的应用的目录中,默认为htdocs目录:sudo c...
    99+
    2023-06-09
  • Linux下如何部署redis
    这篇文章主要介绍“Linux下如何部署redis”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Linux下如何部署redis”文章能帮助大家解决问题。简单来说 redis 就是一个数据库,不过与传统...
    99+
    2023-06-27
  • Linux下如何部署XAMPP
    这篇文章主要介绍“Linux下如何部署XAMPP”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Linux下如何部署XAMPP”文章能帮助大家解决问题。XAMPP是一款开源、免费的网络服务器软件,经过...
    99+
    2023-06-27
  • Linux下如何部署RAID5
    这篇文章给大家分享的是有关Linux下如何部署RAID5的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。RAID 5 是一种存储性能、数据安全和存储成本兼顾的存储解决方案。 RAID 5可以理解为是RAID 0和R...
    99+
    2023-06-28
  • Linux下如何部署Keepalived
    这篇文章将为大家详细讲解有关Linux下如何部署Keepalived,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。Keepalived是Linux下一个轻量级别的高可用解决方案。高可用(High Aval...
    99+
    2023-06-27
  • 如何在Kubernetes容器环境下部署Spinnaker ?
    如果你关注Docker,想了解基于Kubernetes的CD实践。那么,Spinnaker可能是多云平台部署工具的最佳选择。本文重点介绍spinnaker的概念、安装与踩过的坑,spinnaker在kubernetes的持续部署,以及线上容...
    99+
    2023-06-04
  • Linux下如何部署war包
    这篇文章主要介绍了Linux下如何部署war包,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。Java web工程,都是打成war包,进行发布,打成war包的好处是不会缺少目录...
    99+
    2023-06-27
  • Ubuntu下如何部署SQL Server 2017
    这篇文章将为大家详细讲解有关Ubuntu下如何部署SQL Server 2017,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。SQL Server 2017 最近已正式发布。这是 SQL Server 历...
    99+
    2023-06-16
  • Linux下如何部署Samba服务
    小编给大家分享一下Linux下如何部署Samba服务,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成。SMB(Server Mes...
    99+
    2023-06-27
  • Linux下如何部署springboot项目
    本文小编为大家详细介绍“Linux下如何部署springboot项目”,内容详细,步骤清晰,细节处理妥当,希望这篇“Linux下如何部署springboot项目”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。在po...
    99+
    2023-07-06
  • Linux下如何部署NFS服务
    这篇文章主要为大家展示了“Linux下如何部署NFS服务”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“Linux下如何部署NFS服务”这篇文章吧。NFS服务器可以让PC将网络中的NFS服务器共享...
    99+
    2023-06-27
  • Linux下如何部署Django项目
    本篇文章给大家分享的是有关Linux下如何部署Django项目,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。Django是由python编写得开放源代码的Web应用框架,Dja...
    99+
    2023-06-28
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作