Mysql必读mysql 5.7.18 安装配置方法图文教程(CentOS7)

前端之家收集整理的这篇文章主要介绍了Mysql必读mysql 5.7.18 安装配置方法图文教程(CentOS7)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

MysqL必读MysqL 5.7.18 安装配置方法图文教程(CentOS7)》要点:
本文介绍了MysqL必读MysqL 5.7.18 安装配置方法图文教程(CentOS7),希望对您有用。如果有疑问,可以联系我们。

介绍如何在Linux下安装MysqL 5.7.18
MysqL实例

1、下载MysqL:官网https://www.MysqL.com/,点击Downlosas,翻到网页底部,下载社区版,一路点下去,选择通用Linux,下载64位那个,注意检查MD5
值.MysqL实例

Mysql必读mysql 5.7.18 安装配置方法图文教程(CentOS7)

MysqL实例

2、安装关键步骤,直接贴出命令
MysqL实例

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
[root@CentOS MysqL]# tar -xzvf MysqL-5.7.17-linux-glibc2.5-x86_64.tar.gz -C /usr/local 
[root@CentOS MysqL]# cd /usr/local 
[root@CentOS local]# mv MysqL-5.7.17-linux-glibc2.5-x86_64 MysqL 
[root@CentOS local]# cd MysqL 
[root@CentOS MysqL]# mkdir data 
[root@CentOS MysqL]# groupadd MysqL 
[root@CentOS MysqL]# useradd -r -g MysqL -s/bin/false MysqL 
[root@CentOS MysqL]# chown -R MysqL:MysqL ./ 
[root@CentOS MysqL]# bin/MysqLd --initialize --user=MysqL --basedir=/usr/local/MysqL --datadir=/usr/local/MysqL/data 
2017-02-23T07:43:03.404885Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 
2017-02- 
 
23T07:43:04.442174Z 0 [Warning] InnoDB: New log files created,LSN=45790 
2017-02-23T07:43:04.588507Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 
2017-02-23T07:43:04.646721Z 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: b5c8e226-f99b-11e6-beb5-b7c1a1e39029. 
2017-02-23T07:43:04.671492Z 0 [Warning] 
 
Gtid table is not ready to be used. Table 'MysqL.gtid_executed' cannot be opened. 
2017-02-23T07:43:04.672338Z 1 [Note] A temporary password is generated for root@localhost: I%e=s+lfx9ko 
[root@CentOS MysqL]# 
 
bin/MysqL_ssl_rsa_setup --datadir=/usr/local/MysqL/data 
Generating a 2048 bit RSA private key 
.....................................+++ 
..............................+++ 
writing new private key to 'ca-key.pem' 
----- 
Generating a 2048 bit RSA private key 
.........................................+++ 
.........................+++ 
writing new private key to 'server-key.pem' 
----- 
Generating a 2048 bit RSA private key 
..................................................+++ 
...................................................................................................................................................................................................+++ 
writing 
 
new private key to 'client-key.pem' 
----- 
[root@CentOS MysqL]# cd support-files 
[root@CentOS support-files]# cp my-default.cnf /etc/my.cnf 
[root@CentOS support-files]# gedit /etc/my.cnf 
[root@CentOS support-files]# cp MysqL.server /etc/init.d/MysqLd 
[root@CentOS support-files]# service MysqLd start 
Starting MysqL.Logging to '/usr/local/MysqL/data/CentOS.cn.err'. 
. SUCCESS! 
[root@CentOS support-files]# ps aux |grep MysqL 
root  18279 0.0 0.0 11764 1576 pts/0 S 17:34 0:00 /bin/sh 
 
/usr/local/MysqL/bin/MysqLd_safe --datadir=/usr/local/MysqL/data --pid-file=/usr/local/MysqL/data/CentOS.cn.pid 
MysqL  18449 1.9 9.5 1182688 177940 pts/0 Sl 17:34 0:00 /usr/local/MysqL/bin/MysqLd -- 
 
basedir=/usr/local/MysqL --datadir=/usr/local/MysqL/data --plugin-dir=/usr/local/MysqL/lib/plugin --user=MysqL --log-error=/usr/local/MysqL/data/CentOS.cn.err --pid-file=/usr/local/MysqL/data/CentOS.cn.pid 
 
--socket=/tmp/MysqL.sock --port=3306 
 
[root@CentOS support-files]# 

一行一行解释:
MysqL实例

把压缩包解压到/usr/local目录下,就是把MysqL安装在该目录下.
MysqL实例

切换到/usr/local,把刚才解压后的文件重命名MysqL.
MysqL实例

MysqL目录下创建data文件夹,用来存储MysqL的数据.
MysqL实例

增加用户MysqL.
MysqL实例

增加用户名MysqL属于MysqL组.
MysqL实例

修改MysqL目录的拥有者和组.
MysqL实例

初始化MysqL,分两步:MysqL实例

第一步,bin/MysqLd  注意后面给的参数,之一部会产生一个临时密码,保存,后面登录数据库要用到;MysqL实例

第二步,bin/MysqL_ssl_rsa_setup,看起来像是对数据库安全的处理,注意后面给的参数.
MysqL实例

切换到support-files目录.
MysqL实例

把my-default.cnf拷贝到 /etc/my.cnf,注意CentOS7自带了一个my.cnf文件,覆盖掉.
MysqL实例

编辑该文件,只对18,19,20,22行修改,如下MysqL实例

MysqL.server文件拷贝到/etc/init.d/MysqLd下,主要负责MysqL的开机启动.
MysqL实例

启动MysqLd进程.
MysqL实例

查询MysqL进程.有两个: /MysqL/bin/MysqLd_safe、/MysqL/bin/MysqLd
MysqL实例

3、后续配置:
MysqL实例

登录MysqL,修改临时密码:/usr/local/MysqL/bin/MysqL -u root -p 回车输入初始化时生成的临时密码,修改密码MysqL实例

set password for  'root'@localhost=password('xxxxxx');
MysqL实例

每次登录MysqL客户端嫌输绝对路径麻烦,就建一个软连接:ln -s  /usr/local/MysqL/bin/MysqL  /usr/bin/MysqL,这样也省去了配PATH路径的麻烦.
MysqL实例

MysqLd的开机启动,使用chkconfig命令
MysqL实例

chkconfig --add MysqLd #增加MysqLd服务
chkconfig --list    #列出所有的系统服务

看一下是不是在所有等级都是打开状态,例如:MysqL实例

chkconfig --level 35 MysqLd on 
#设定MysqLd在等级3和5为开机运行服务

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家PHP.MysqL实例

猜你在找的MySQL相关文章