Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

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:

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

ogrew
メインをはてブに変えました。
http://taiga.hatenadiary.com
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした