码迷,mamicode.com
首页 > 数据库 > 详细

CentOS 7.2 下 mysql 8.0.11二进制安装(亲测)

时间:2018-07-25 16:10:56      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:ESS   配置   safe   flush   pts   ice   source   creat   option   

本文主要介绍mysql 8.0.11二进制安装,具体步骤如下

1. 解压文件

tar -zxvf mysql-8.0.11-el7-x86_64.tar.gz


2. 移动解压后的数据库文件

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


3. 创建mysql组

groupadd mysql


4. 创建mysql用户并添加到mysql组

useradd -g mysql mysql


5. 创建data目录

mkdir /data


6. 修改目录权限

chown -R mysql.mysql /data

chown -R mysql.mysql /usr/local/mysql


7. 创建my.cnf文件(etc目录下已有my.cnf,可先删除)

vi /etc/my.cnf

[mysqld]

port      = 3306

socket    = /tmp/mysql.sock

basedir   = /usr/local/mysql

datadir   = /data

log-error = mysql02_err.log

server-id = 330602


8. 初始化数据库

(mysql 8.0.11是没有/bin/mysql_install_db脚本的,有的人写教程仍在用来误导新人,安装不成功的请注意。官档可查)

#有密码初始化

/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize

无密码初始化

/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize-insecure


9. 查看密码

cat /data/mysql02_err.log

2018-07-25T14:10:46.576739Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 9796

2018-07-25T14:10:49.072963Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: iN:.snX3P_in

2018-07-25T14:10:50.825865Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.11) initializing of server has completed


10. 启动数据库

/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &


[1] 9925

2018-07-25T14:20:27.230347Z mysqld_safe Logging to '/data/mysql02_err.log'.

2018-07-25T14:20:27.267638Z mysqld_safe Starting mysqld daemon with databases from /data


11. 登录数据库

/usr/local/mysql/bin/mysql -uroot -p


12. 第一次登录修改root初始化密码

alter user 'root'@'localhost' identified with mysql_native_password by '123456'


13. 创建root@%

create user 'root'@'%' identified by '123456';

grant all privileges on *.* to 'root'@'%' with grant option;

flush privileges;


14. 配置环境变量

vi /etc/profile 在最后添加:

PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH

source /etc/profile


15. 关闭数据库

mysqladmin -uroot -p shutdown


16. 启动数据库

mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &


17. 查看数据库进程

[root@mysql02 data]# ps -ef|grep mysql

root      10253   9892  0 10:48 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql

mysql     10405  10253 16 10:48 pts/2    00:00:01 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=mysql02_err.log --pid-file=mysql02.pid --socket=/tmp/mysql.sock --port=3306

root      10447   9892  0 10:49 pts/2    00:00:00 grep --color=auto mysql


18. 将mysql服务加到系统服务中

cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server

chmod +x /etc/rc.d/init.d/mysql.server

chkconfig --add mysql.server

chkconfig --list mysql.server


19. 关闭数据库

service mysql.server stop

[root@mysql02 etc]# service mysql.server stop

Shutting down MySQL..2018-07-25T15:33:26.490180Z mysqld_safe mysqld from pid file /data/mysql02.pid ended

SUCCESS!

[1]+  Done                    mysqld_safe --defaults-file=/etc/my.cnf --user=mysql  (wd: /data)

(wd now: /etc)


20. 启动数据库

sudo -u mysql service mysql.server start

[root@mysql02 etc]# sudo -u mysql service mysql.server start

Starting MySQL.. SUCCESS!


21. 查看服务

ps  -ef|grep mysql

[root@mysql02 etc]# ps -ef|grep mysql

mysql     10833      1  0 11:35 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data --pid-file=/data/mysql02.pid

mysql     11003  10833 10 11:35 pts/2    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=mysql02_err.log --pid-file=/data/mysql02.pid --socket=/tmp/mysql.sock --port=3306

root      11047   9892  0 11:36 pts/2    00:00:00 grep --color=auto mysql


22. 重启数据库

sudo -u mysql service mysql.server restart

[root@mysql02 etc]# sudo -u mysql service mysql.server restart

Shutting down MySQL.. SUCCESS!

Starting MySQL. SUCCESS!

技术分享图片技术分享图片

(本文出处:易语随风去   http://blog.51cto.com/aimax)

CentOS 7.2 下 mysql 8.0.11二进制安装(亲测)

标签:ESS   配置   safe   flush   pts   ice   source   creat   option   

原文地址:http://blog.51cto.com/aimax/2150021

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!