问题
I reinstalled the server running MySQL. I had created a backup of the database by using MySQL Workbench. Now I'm trying to import the dump in to the database trough the same program but I get the following error:
ERROR 1142 (42000) at line 656: SELECT,LOCK TABL command denied to user 'root'@'MIKKOS' for table 'events_waits_summary_by_thread_by_event_name'
I tought that root had full privileges. I ran the following but the same error appears with the previous query after executing this:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION
It also appears when running locally (root@localhost).
What to do?
回答1:
Check which databases MySQL Workbench included in the dumpfile. I believe it defaults to dumping everything, including DBs like user
and performance_schema
. Those are the problem, your grant tables are probably fine.
Remove the unneeded databases, especially performance_schema
and MySQL will likely import the dumpfile without errors.
回答2:
You need to repair internal table structure after reinstallation a newer MySQL server. To do so try:
REPAIR TABLE `events_waits_summary_by_thread_by_event_name`;
It would be better to drop database and restore it from full mysql database dump if you have one.
来源:https://stackoverflow.com/questions/14423686/error-1142-select-and-lock-table-commands-denied