升級MySQL 5.7版本遇到的一些小問題

來源:互聯網
上載者:User

標籤:mysql

在5.6版本伺服器做備份

/usr/local/mysql/bin/mysqldump -S /tmp/mysql3306.sock -A -p --set-gtid-purged=OFF > backup_20160204.sql

 

在5.7版本伺服器操作

mkdir -p /neworiental/data/mysql/mysql3307/{data,logs,relaylog,sock,tmp}

chown -R mysql:mysql /neworiental/data

 

初始化資料庫
/usr/local/mysql/bin/mysqld --defaults-file=/neworiental/data/mysql/mysql3307/my3307.cnf  --initialize-insecure

 

恢複資料庫(全量資料)
/usr/local/mysql/bin/mysql -S /neworiental/data/mysql/mysql3307/sock/mysql3307.sock -p  <    backup_20160204.sql

 

查看所有使用者沒有密碼!!!

select user,host,authentication_string,plugin from mysql.user;

 

修改密碼

UPDATE mysql.user SET authentication_string=PASSWORD(‘password‘) WHERE User=‘root‘ and host=‘localhost‘;
FLUSH PRIVILEGES;
驗證登入,登出,正常
重啟之後,還是正常

 

只有日誌有報錯
2016-02-04T08:26:56.700344Z 0 [ERROR] Incorrect definition of table mysql.db: expected column ‘User‘ at position 2 to have type char(32), found type char(16).
2016-02-04T08:26:56.700391Z 0 [ERROR] mysql.user has no `Event_priv` column at position 28
2016-02-04T08:26:56.700574Z 0 [ERROR] Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.

 

進行資料庫升級
/usr/local/mysql/bin/mysqld_safe --defaults-file=/neworiental/data/mysql/mysql3307/my3307.cnf --skip-grant-tables &
/usr/local/mysql/bin/mysql_upgrade --defaults-file=/neworiental/data/mysql/mysql3307/my3307.cnf -p --force
重啟之後,日誌正常了

 

問題語句:(5.7.10)
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘localhost‘ IDENTIFIED BY  ‘password‘   WITH GRANT OPTION;

650) this.width=650;" title="1.jpg" style="float:none;" src="http://s4.51cto.com/wyfs02/M02/7A/C1/wKiom1azHkTRvszWAAJw5JqBkkY348.jpg" alt="wKiom1azHkTRvszWAAJw5JqBkkY348.jpg" />

系統資料表欄位已亂

650) this.width=650;" title="2.jpg" style="float:none;" src="http://s5.51cto.com/wyfs02/M00/7A/C0/wKioL1azHpeynCHCAAJclnC0nrU008.jpg" alt="wKioL1azHpeynCHCAAJclnC0nrU008.jpg" />

日誌中記錄 noboby can currently load!!!

650) this.width=650;" title="3.jpg" style="float:none;" src="http://s1.51cto.com/wyfs02/M00/7A/C1/wKiom1azHkeCumtWAAC-cfpwq0k749.jpg" alt="wKiom1azHkeCumtWAAC-cfpwq0k749.jpg" />

無法登陸

650) this.width=650;" title="4.jpg" style="float:none;" src="http://s3.51cto.com/wyfs02/M01/7A/C1/wKiom1azHkfSlg8JAADW6uXr48s673.jpg" alt="wKiom1azHkfSlg8JAADW6uXr48s673.jpg" />

無法停止

 

以下是解決辦法:

650) this.width=650;" title="5.jpg" style="float:none;" src="http://s2.51cto.com/wyfs02/M02/7A/C1/wKiom1azHkqDNCx3AAPCMO0vBXE208.jpg" alt="wKiom1azHkqDNCx3AAPCMO0vBXE208.jpg" />


解決辦法:
UPDATE mysql.user SET authentication_string=PASSWORD(‘password‘) WHERE User=‘root‘ and host=‘localhost‘;
UPDATE mysql.user SET plugin=‘mysql_native_password‘  WHERE User=‘root‘ and host=‘localhost‘;
FLUSH PRIVILEGES;
1.已驗證,此語句在5.6.28版本運行正常。(因為是源庫,因為是一個版本,因為沒有發生遷移)
2.無論是覆蓋,還是建立,都不行  (版本問題,後面會說)

 

之前還殘留兩個5.7問題
1.恢複之後的資料庫,mysql.user所有使用者沒有密碼!!! (見結論)
2.使用全庫恢複,會把‘mysql.sys‘@‘localhost‘覆蓋,不知是否有影響?->必須有影響! (見結論)

 


結論&解決辦法已驗證
因為資料庫版本問題,全庫恢複之後,系統資料表會被覆蓋,(變相的給降級了!!!)所以誇版本的情況,全庫dump,恢複之後,必須做版本update,然後重啟資料庫!!!

 


 

本文出自 “bigbear” 部落格,請務必保留此出處http://bigbear1206.blog.51cto.com/1671415/1741130

升級MySQL 5.7版本遇到的一些小問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.