MySQL 5.5 升級到 MySQL5.6,在什麼都沒有更改的情況下,直接將data放置到MySQL 5.6下運行,一開始就一切正常,但在新加一個數據庫後,分配權限時,就出錯了:
ERROR 2013 (HY000): Lost connection to MySQL server during query
一開始以為是連接不上socket,因為同時有看到錯誤:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock
但查看之後,發現sock正常,沒任何問題,然後就跑到官網下面看mysql 5.6升級指南,其中有這麼一段:
After upgrading to a new version of MySQL, run mysql_upgrade (see Section 4.4.7, “mysql_upgrade — Check and Upgrade MySQL Tables”). This program checks your tables, and attempts to repair them if necessary. It also updates your grant tables to make sure that they have the current structure so that you can take advantage of any new capabilities. (Some releases of MySQL introduce changes to the structure of the grant tables to add new privileges or features.)
mysql_upgrade does not upgrade the contents of the help tables. For upgrade instructions, see Section 5.1.10, “Server-Side Help”.
mysql_upgrade should not be used when the server is running with --gtid-mode=ON, since it may make changes in nontransactional system tables in the mysql database, many of which are MyISAM and cannot be changed to use a different storage engine. See GTID mode and mysql_upgrade.
那就明白了,執行一下:
mysql_upgrade -u root -p
執行完後,再執行grant語句,問題解決。