1. 程式人生 > >Linux CentOS7 安裝 Mysql5.7.19

Linux CentOS7 安裝 Mysql5.7.19

tar ice 改密碼 mysql base -- share 密碼 chgrp

1.解壓文件

[[email protected] ~]# tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

技術分享

2.重命名

[[email protected] ~]# cd /usr/local/

[[email protected] local]# mv mysql-5.7.19-linux-glibc2.12-x86_64/ mysql

技術分享

3.配置環境變量

[[email protected] local]# vi + /etc/profile

技術分享

[[email protected] local]# source /etc/profile

4.創建組和用戶並授權

[[email protected] local]# groupadd mysql

[[email protected] local]# useradd -r -g mysql -s /bin/false mysql

[[email protected] local]# chown -R mysql mysql/
[[email protected] local]# chgrp -R mysql mysql/

技術分享

5.初始化並記住最後的12位密碼

[[email protected] local]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=zh_CN

技術分享

6.修改mysql.server.文件並復制到 /etc/init.d/目錄下

[[email protected] local]# cd /usr/local/mysql/support-files/
[[email protected] support-files]# vi mysql.server

技術分享

[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld

7.重命名my.cnf

[[email protected] support-files]# mv /etc/my.cnf /etc/my_default.cnf

8.設置開機啟動

[[email protected] support-files]# chmod +x /etc/init.d/mysqld
[[email protected] support-files]# chkconfig --add mysqld
[[email protected] support-files]# chkconfig mysqld on

//查看開機啟動是否成功

[[email protected] support-files]# chkconfig --list mysqld

技術分享

9.啟動服務

[[email protected] support-files]# /etc/init.d/mysqld start
[[email protected] support-files]# service mysql start

技術分享

10.登錄修改密碼,密碼就是第5步系統生成的

[[email protected] support-files]# mysql -uroot -p

mysql> set password=password("1234");

技術分享

Linux CentOS7 安裝 Mysql5.7.19