Mysql ERROR 1045 (28000) in ubuntu: how to solve the problem of Access denied for user root @ localhost, ubuntu28000
Method 1:
Skip-grant-tables: very useful mysql startup parameters
This section describes a very useful mysql startup parameter -- skip-grant-tables. As the name implies
Grant-tables is not enabled for mysql. What is the purpose? Of course, it is useful when you forget the administrator password.
Start mysql with command line parameters: #/usr/bin/mysqld_safe -- skip-grant-tables &
3. Modify the administrator password:
Use mysql;
Update user set password = password ('yournewpasswordhere ') where user = 'root'; flush privileges; exit;
4. Kill mysql and restart mysql.
Then you can log on directly.
Method 2:
View the mysql installation path
Then we change the password of the root user,
View default password first
Then log on directly.
Then change the root default user name and password.
Grant all privileges on *. * to 'root' @ 'localhost' identified by 'Password'; flush privileges;
Mysql> update mysql. user set password = password ('new password') where User = "test" and Host = "localhost ";
Mysql> flush privileges;
Mysql> delete from user where User = 'root' and Host = 'localhost ';
Mysql> flush privileges;
Mysql> grant select, delete, update, create, drop on *. * to test @ "%" identified by "1234 ";
Mysql> UPDATE user SET Host = '2017. 0.0.1 'WHERE User = 'root' AND Host = 'localhost ';
Mysql> flush privileges;
Modify Grant_priv to 'y' (flush privileges; (execute this statement or restart MySQL to take effect) and update mysql. user set Grant_priv = 'y' where user = 'ptmind ';