Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
5
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

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

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:

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
5
Help us understand the problem. What are the problem?