在centos6.7上安裝mysql5.7.18

首先下載mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

然後解壓 ta'r -xvzf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

要想好 datadir 和basedir兩個路徑。

我把這個壓縮包,解壓後,重名爲爲mysql,放在 /opt/mysql

然後/opt/mysql/下面有個bin文件

 

bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql_data_file/

執行完了,會出現一個臨時密碼,一定要記住這個臨時密碼:

[hadoop@Master mysql]$ sudo bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql_data_file/

2018-10-25T06:48:28.899955Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2018-10-25T06:48:29.467625Z 0 [Warning] InnoDB: New log files created, LSN=45790

2018-10-25T06:48:29.645286Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2018-10-25T06:48:29.786048Z 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: fb628d21-d821-11e8-8cdc-005056b20471.

2018-10-25T06:48:29.804129Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2018-10-25T06:48:29.804705Z 1 [Note] A temporary password is generated for root@localhost: >xHYOl:s<6V7

 

 

如果要裝ssl,那麼緊接着要執行下面這一步:

bin/mysql_ssl_rsa_setup      --basedir=/opt/mysql --datadir=/opt/mysql_data_file/

 

 

將mysql進程放入系統進程中,命令如下:

先修改這個support-files/mysql.server,把裏面的basedir和datadir都改一下。

然後

cp support-files/mysql.server /etc/init.d/mysqld

如果my.cnf 不存在,可以直接複製別人的my.cnf過來。改下對應參數。

 

啓動 sudo /etc/init.d/mysqld restart

第一次root賬號進去,會要求你改密碼:

alter user 'root'@'localhost' identified by 'zhelishinizijishezhidexinmima';

 

 

參考:

生成pem :https://www.cnblogs.com/mysql-dba/p/7061300.html
安裝mysql:http://www.bubuko.com/infodetail-2164257.html

 

注意,如果感覺裝得不對,可以重來的,很簡單,就是把datadir下面的都清除(都刪掉),

然後重新執行

bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql_data_file/

 

 

要注意basefile 和 datafile的所有者必須是mysql,經常要執行

chown -R mysql:mysql  /opt/files/mysql

chown -R mysql:mysql  /opt/files/mysql_data_file

 

還有,

use user;

select * from user where user='root';

update user set password_expired ="NO" where user='root';

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章