Если пытаясь сменить пароль root пользователя в MySQL и вам это не удается
mysql> UPDATE mysql.user SET Password=PASSWORD('ПАРОЛЬ') WHERE User='root'; Query OK, 0 rows affected (0.00 sec) Rows matched: 0 Changed: 0 Warnings: 0 |
mysql> select * from user where User='root'; Empty set (0.00 sec) |
Это значит что ваша таблица данных mysql.user утеряна.
Теперь посмотрим на то, как это восстановить.
Останавливаем mysql
/etc/init.d/mysql stop |
Запустите mysqld_safe
mysqld_safe -–skip-grant-tables & |
Входим
mysql mysql> use mysql; |
Проверяем
mysql> select * from user where User='root'; Empty set (0.00 sec) |
Данных нет … Восстанавливаем.
mysql>INSERT INTO user (Host,User,Password,Select_priv,Insert_priv) VALUES('localhost','root',PASSWORD('ПАРОЛЬ'),'Y','Y'); UPDATE user set Update_priv = 'Y' WHERE User='root'; UPDATE user set Delete_priv = 'Y' WHERE User='root'; UPDATE user set Create_priv = 'Y' WHERE User='root'; UPDATE user set Drop_priv = 'Y' WHERE User='root'; UPDATE user set Reload_priv = 'Y' WHERE User='root'; UPDATE user set Shutdown_priv = 'Y' WHERE User='root'; UPDATE user set Process_priv = 'Y' WHERE User='root'; UPDATE user set File_priv = 'Y' WHERE User='root'; UPDATE user set Grant_priv = 'Y' WHERE User='root'; UPDATE user set References_priv = 'Y' WHERE User='root'; UPDATE user set Index_priv = 'Y' WHERE User='root'; UPDATE user set Alter_priv = 'Y' WHERE User='root'; UPDATE user set Show_db_priv = 'Y' WHERE User='root'; UPDATE user set Super_priv = 'Y' WHERE User='root'; UPDATE user set Create_tmp_table_priv = 'Y' WHERE User='root'; UPDATE user set Lock_tables_priv = 'Y' WHERE User='root'; UPDATE user set Execute_priv = 'Y' WHERE User='root'; UPDATE user set Repl_slave_priv = 'Y' WHERE User='root'; UPDATE user set Create_view_priv = 'Y' WHERE User='root'; UPDATE user set Show_view_priv = 'Y' WHERE User='root'; UPDATE user set Create_routine_priv = 'Y' WHERE User='root'; UPDATE user set Alter_routine_priv = 'Y' WHERE User='root'; UPDATE user set Create_user_priv = 'Y' WHERE User='root'; |
mysql> flush privileges; mysql> exit |
Рестартуем MySQL
/etc/init.d/mysql restart |
логинимся
mysql -u root -p |