ERROR 1044 (42000): Access denied for user ''@ 'localhost' to database 'mysql'. Solution: 104442000
The newly installed mysql database encountered a problem when accessing the mysql database: ERROR 1044 (42000): Access denied for user ''@ 'localhost' to database 'mysql ',
[Root @ dzwww.mysql-5.1.61] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor.Commands end with; or \ g.
Your MySQL connection id is 1
Server version: 5.1.61 Source distribution
Copyright (c) 2000,201 1, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql> use mysql
ERROR 1044 (42000): Access denied for user ''@ 'localhost' to database 'mysql'
Mysql>
The solution is as follows:
Open my. ini and go
[Mysqld]
Skip-external-locking
Skip-name-resolve
# Skip-grant-tables
Skip-grant-tables is commented out when skipping permission verification. Remove the comment and restart mysql:
[Root @ aaa libexec] #/usr/local/mysql/libexec/mysqld -- basedir =/usr/local/mysql -- datadir =/data0/mysqldata -- user = mysql -- log- error =/data0/mysqldata/mysql-error.log -- open-files-limit = 20000 -- pid-file =/data0/mysqldata/dzwww.com-B15-5-3-36.pid -- socket =/tmp/mysql. sock -- Ports = 3306
[Root @ dzwww.mysql-5.1.61] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor.Commands end with; or \ g.
Your MySQL connection id is 1
Server version: 5.1.61-log Source distribution
Copyright (c) 2000,201 1, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql> use mysql
Database changed
Mysql> grant all privileges on *. * to root @ localhost identified by 'mysql'
Then log on to OK again!