mysql> use mysql
ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘mysql’
Solution:
# mysqld_safe –skip-grant-table
161104 10:36:00 mysqld_safe Logging to ‘/var/log/mysqld.log’.
161104 10:36:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
At this point the terminal is in a waiting state, open another terminal to change the root password of mysql
# mysql -u root
mysql> update user set password=PASSWORD(”) where user=’root’; # Here I set the root password to null
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3 Changed: 0 Warnings: 0
mysql> delete from user where user=”; # Delete this ”@’localhost” user, otherwise it will still default to this user after login
Query OK, 2 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
After changing the root password of mysql, stop the mysqld service, at this point, the above terminal will stop waiting.
# /etc/init.d/mysqld restop
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
The problem is solved by logging into mysql again.
Similar Posts:
- [Solved] MYSQL8 Error: ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)
- MYSQL Login Error: mysqladmin: connect to server at ‘localhost’ failed
- [Solved] MYSQL ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘mys…
- MySQLAccess denied for user ‘root’@’localhost’ [How to Solve]
- mysql ERROR 1044 (42000): Access denied for user ‘
- ERROR 1044 (42000): Access denied for user ‘root’@’localhost’
- How to Solve MYSQL error “no directory, logging in with home = -“
- Solution to the error of MySQL: unrecognized service (CentOS)
- ERROR 1820 (HY000): Unknown error 1820 [How to Solve]
- [Solved] Error 1054 (42s22) unknown column ‘password’ in ‘field list’ when updating the password of mysql5.7 or above