1. 程式人生 > >CentOS6.5快速搭建MySQL8.0.12(tar包方式)

CentOS6.5快速搭建MySQL8.0.12(tar包方式)

1. 官網下載資源

伺服器yum方式太慢了,所以選用tar包解壓方式,有壓縮和未壓縮的兩種,大小不一樣,我下載的是xz包

解壓命令:xz -d abc.tar.xz   解出的tar包繼續執行:tar -xvf abc.tar

如提示xz沒安裝:yum -y install  xz

2. 參考文件初始化(參考官方refman8.0-en文件2.2節)

首先執行:

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

cd進入bin資料夾執行初始化程式:mysqld --initialize --user=mysql

如果提示:error while loading shared libraries: libnuma.so.1  ,yum安裝下這個庫:yum -y install numactl,再執行上面的語句。

正確輸出如下(注意記錄好臨時密碼!):

2018-10-18T10:04:57.800365Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

2018-10-18T10:04:57.800572Z 0 [System] [MY-013169] [Server] /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.12) initializing of server in progress as process 3655

2018-10-18T10:05:01.094610Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: SkpVw0jqv?AB

2018-10-18T10:05:03.680974Z 0 [System] [MY-013170] [Server] /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.12) initializing of server has completed

 

 

新增服務指令碼,可選:cp support-files/mysql.server /etc/init.d/mysql.server    這樣可以快速啟動和重啟服務(自己試了下還是有問題,摸索中。。。。)

 

3. 登陸root賬戶更改預設密碼

mysql -h 127.0.0.1 -u root -p  之後輸入上一步的預設密碼

執行show databases 會提示:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

更改預設密碼:ALTER USER USER() IDENTIFIED BY '123456abc';    

之後使用新密碼登陸,再次執行show databases;

成功!之後可以建立使用者,建表和使用了!

 

預設情況下root使用者無法遠端登入,解決方案:本地登陸後執行如下語句:

use mysql;

update user set host = '%' where user = 'root’;

FLUSH PRIVILEGES