在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;
系統表字段已亂
日志中記錄 noboby can currently load!!!
無法登陸
無法停止
以下是解決辦法:
解決辦法:
UPDATE mysql.user SET plugin=‘mysql_native_password‘ WHERE User=‘root‘ and host=‘localhost‘;
1.已驗證,此語句在5.6.28版本運作正常。(因為是源庫,因為是一個版本,因為沒有發生遷移)
2.無論是覆寫,還是建立,都不行 (版本問題,後面會說)