標籤:sha ror var hang involve network password lock existing
兩種升級方式
In-Place Upgrade: Involves shutting down the old MySQL version, replacing the old MySQL binaries or packages with the new ones, restarting MySQL on the existing data directory, and running mysql_upgrade.
Logical Upgrade: Involves exporting existing data from the old MySQL version using mysqldump, installing the new MySQL version, loading the dump file into the new MySQL version, and running mysql_upgrade.
主從的升級:
- 主從想都替換二進位安裝包為最新版本
- 停從,通過mysql_upgrade升級後,加參數 --skip-slaves-start 進行啟動
- 加參數 --skip-networking重啟主,拒絕來自應用的TCP/IP的串連,關閉binlog,執行mysql_upgrade,然後重啟
- 注意點:在關閉服務時加參數 --innodb_fast_shutdown=0 (slow shutdown),會將所有提交的事務對應的髒頁重新整理到資料檔案中,預設是1(fast shutdown 參考文獻:http://dev.mysql.com/doc/refman/5.7/en/glossary.html#glos_fast_shutdown)
MySQL5.6版本到5.7版本的更新包括一些不相容的特性,在升級到5.7之前,我們需要知道這些不相容的特性並手動更新,在其中涉及到REPAIR TABLE和USE_FRM選項的指令一定要在更新版本之前完成。配置項更新
MySQL5.7.11,此參數的預設值為keyring_file(是一個二進位檔案的外掛程式),InnoDB資料表空間在初始化InnoDB之前需要此外掛程式來加密,但是MySQL5.7.12及以後此參數預設為空白,所以5.7.11升級到5.7.12後,如果已經在之前的版本中使用此外掛程式對InnoDB資料表空間進行了加密,在開啟服務時需要指定參數 --early-plugin-load
MySQL5.6中INFORMATION_SCHEMA 中存在系統變數和狀態變數的表,show variables 和show status也是基於此庫中的表,在5.7.6時被Performance Schema也存在這四張表,show 語句開始基於Performance Schema中的表,如果show_compatibility_56參數開啟,則相容5.6
下面的測試庫是從MySQL5.6版本中直接物理恢複到MySQL5.7環境下的
mysql> select version();+------------+| version() |+------------+| 5.7.10-log |+------------+1 row in set (0.00 sec)
mysql> show variables like ‘%56%‘;
ERROR 1146 (42S02): Table ‘performance_schema.session_variables‘ doesn‘t exist
mysql> use performance_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables like ‘%variable%‘;
Empty set (0.00 sec)
mysql> set global show_compatibility_56=ON;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like ‘%56%‘;
+-----------------------------+-------+
| Variable_name | Value |
+-----------------------------+-------+
| sha256_password_proxy_users | OFF |
| show_compatibility_56 | ON |
+-----------------------------+-------+
2 rows in set (0.00 sec)
- 使用mysqld --initialize (or mysqld --initialize-insecure).初始化執行個體
sql mode
ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES, NO_ENGINE_SUBSTITUTION預設開啟
如以下sql在only full group by下,name非聚集字列,如果不在乎返回的address的值是否準確,則可以使用ANY_VALUE函數,這樣address欄位就無需滿足full group by 出現在group by 中
SELECT name, ANY_VALUE(address), MAX(age) FROM t GROUP BY name;
系統資料表的改變
mysql.user的password欄位在5.7.6中已去除,認證資訊記錄在authentication_string中,運行in-place upgrade 遷移password列值到authentication_string
如果是通過logical upgrade,需要注意:
server端的更改
MySQL5.7.5開始mysql_old_password 外掛程式被移除
secure-auth 系統變數僅支援值1
--skip-secure-auth 選項被棄用
old_password系統變數的值1(將密碼hash為41位的hash值)不再被允許
old_password ()函數被移除
欄位類型YEAR(2)被更改為YEAR(4)
MySQL5.7.2開始mysql.user系統資料表中的plugin欄位不允許為空白,運行mysql_upgrade會進行如下操作
UPDATE mysql.user SET plugin = ‘mysql_native_password‘WHERE plugin = ‘‘ AND (Password = ‘‘ OR LENGTH(Password) = 41);FLUSH PRIVILEGES;
需要注意sql_mode的變更,如:
mysql> SET sql_mode = ‘‘;Query OK, 0 rows affected (0.00 sec)mysql> CREATE TABLE t (d DATE DEFAULT 0);SET sql_mode = ‘NO_ZERO_DATE,STRICT_ALL_TABLES‘;INSERT INTO t (d) VALUES(DEFAULT);Query OK, 0 rows affected (0.52 sec)mysql> SET sql_mode = ‘NO_ZERO_DATE,STRICT_ALL_TABLES‘;Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> INSERT INTO t (d) VALUES(DEFAULT);ERROR 1292 (22007): Incorrect date value: ‘0000-00-00‘ for column ‘d‘ at row 1
SQL變更
MySQL5.7.5之前GET_LOCK()在執行第二次的額時候會釋放前面獲得的鎖,在此版本以後支援同時獲得多個鎖,如:
mysql> select version();+------------+| version() |+------------+| 5.6.33-log |+------------+1 row in set (0.00 sec)mysql> SELECT GET_LOCK(‘lock1‘,10);+----------------------+| GET_LOCK(‘lock1‘,10) |+----------------------+| 1 |+----------------------+1 row in set (0.00 sec)mysql> SELECT GET_LOCK(‘lock2‘,10);+----------------------+| GET_LOCK(‘lock2‘,10) |+----------------------+| 1 |+----------------------+1 row in set (0.00 sec)mysql> SELECT RELEASE_LOCK(‘lock2‘);+-----------------------+| RELEASE_LOCK(‘lock2‘) |+-----------------------+| 1 |+-----------------------+1 row in set (0.00 sec)mysql> SELECT RELEASE_LOCK(‘lock1‘);+-----------------------+| RELEASE_LOCK(‘lock1‘) |+-----------------------+| NULL |+-----------------------+1 row in set (0.00 sec)
返回null說明此鎖已經被釋放了
參考文獻:
http://dev.mysql.com/doc/refman/5.7/en/upgrading-from-previous-series.html
MySQL版本升級之5.6到5.7