LoginSignup
12
6

More than 5 years have passed since last update.

MySQL ver5.7でmysqldumpしようとしてエラーが出たときの対処法

Last updated at Posted at 2017-12-26

databaseのバッグアップを取ろうとして一旦sqlファイルに落とそうとしたら、MySQLから次のようなエラーが出ました。

$ mysqldump -uroot -p hogehoge >hogehoge.sql
Enter password:
mysqldump: Couldn't execute 'SHOW VARIABLES LIKE 'gtid\_mode'': Table 'performance_schema.session_variables' doesn't exist (1146)

むむむっ!?
エラー文言を読む限り「テーブルの構造が違うぞ」ってことみたいですが、  
ググったところ、これはMySQL自体をUpgradeすれば解決するようです。

$ mysql_upgrade -u root -p
Enter password:
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
(~~~中略~~~)
Upgrade process completed successfully.
Checking if update is needed.

終わったら再トライ。

$ mysqldump -uroot -p hogehoge >hogehoge.sql
Enter password:
mysqldump: Couldn't execute 'SHOW VARIABLES LIKE 'gtid\_mode'': Native table 'performance_schema'.'session_variables' has the wrong structure (1682)

今度もまた似たようなエラーですが今度はwrong structureと出ています。  
とりあえずMySQL Server自体を再起動します。

$ mysql.server stop
Shutting down MySQL
.. SUCCESS!

$ mysql.server start
Starting MySQL
. SUCCESS!

$ mysqldump -uroot -p hogehoge >hogehoge.sql
Enter password:

今度は無事成功しました。

12
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
6