用户'root'@'localhost'的MYSQL访问被拒绝 [英] MYSQL Access denied for user 'root'@'localhost'
本文介绍了用户'root'@'localhost'的MYSQL访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我执行了以下步骤以在Ubuntu中使用MySQL:
I did the following steps to use MySQL in Ubuntu:
sudo aptitude install php5-mysql mysql-server
sudo service mysql stop
sudo mysqld_safe --skip-grant-tables &
sudo mysql -u root mysql
更改root密码:
mysql> UPDATE mysql.user SET Password=PASSWORD('SecurePassword') WHERE
User='root';
mysql> FLUSH PRIVILEGES;
mysql> EXIT
修改/etc/mysql/my.cnf:
Modify /etc/mysql/my.cnf:
[client]
user=root
password=SecurePassword
[mysqld]
...
default-time-zone = '+0:00'
然后:
sudo service mysql start
mysql -u root
mysql> SHOW GRANTS FOR root@localhost
+--------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+--------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '[here is the Securepassword]' |
+-------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
我收到一个错误:
拒绝用户'root'@'localhost'的访问(使用密码:是)
Access denied for user 'root'@'localhost' (using password: YES)
推荐答案
您所做的工作绝对正确,但是我认为它不起作用的原因有一个.
It was absolutely correct what you did, but I guess it's not working for one small reason.
要授予这样的特权时,应使用identified by password
:
You should use identified by password
when you are going to grant privileges like this:
mysql> GRANT ALL PRIVILEGES ONE `*`.`*` TO 'root'@'localhost' IDENTIFIED BY PASSWORD
'*A4B6157319038724E3560894F7F932C8886EBFCF' WITH GRANT OPTION;
这篇关于用户'root'@'localhost'的MYSQL访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文