ERROR 1142 (42000): SELECT command denied to user '
(2016-02-20 16:22:15)ERROR: Access denied for user 'root'@'localhost' (using password: NO)
试了很多方法,只有这个作者的方法能解决,感谢作者。
=========================
在授权的时候报错:
ERROR 1044 (42000):
Access denied for user 'root'@'%' to database 'mdm'
首先这里是用root用户操作,所以对这个数据库的权限绝对是最高级的,但是如果是非root用户操作,就可能是权限的问题,需要root用户授权。
再来查看一下每种方式下的root用户的具体权限:
mysql> select * from user\\G;
我这里root有三种解析登录方式分别是:Host: bidevedw\_db、Host: ::1、Host: %
一般情况还有Host:127.0.0.1、Host:localhost我的里面把哪两种删了。
请注意 !
这个表示,以这种方式解析登录的root用户,是否有grant权限,Y则表示有授权限给其他用户的权限,N表示没有。
这里恰好,就是我们要找的原因,因为我的/my.cnf文件里面有skip-name-resolve参数,所以root都是解析到@'%'方式登录,于是就没有grant_priv权限。
解决方法:
1、在不重启MySQL服务的情况下,只需要在登录的时候加上-h参数。
例如:(a). /usr/local/mysql/bin/mysql -uroot -p123456 -h::1
2、需要重启MySQL。把skip-name-resolve参数去掉
=========================================
HTTP Status 500 - javax.servlet.ServletException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
use mysql
update user set password=password('xxxxxxxxxx') where
user='root';
flush privileges;
====================================================
ERROR 1045
(28000):
-----------------------------
/etc/init.d/mysqld status
/etc/init.d/mysqld stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking
&
需要使用Enter中断会话
mysql -u root -p -hlocalhost
mysql> use mysql;
select Host, User, Password from user where user='root' and
host='root' or host='localhost';
+-----------+--------+----------+
|
Host
+-----------+--------+----------+
| localhost
|
| localhost | aimin
| localhost | nobody
|
| localhost | root
+-----------+--------+----------+
4 rows in set (0.00 sec)
update user set password=PASSWORD('XXXXXXXXXXXXXX') where
user='root' and host='root' or host='localhost';
flush privileges;
quit
/etc/init.d/mysqld restart
mysql -u root -p -hlocalhost
----------------------------------------------
# service mysqld stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking
&
# mysql -u root -p -hlocalhost
mysql> UPDATE user SET
Password=PASSWORD('xxxxxxxxxxxxxxxxxxxxx') where
USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# service mysqld start
restart CentOS.
-------------------------------------
Access denied for user
'root'@'localhost' (using password: YES)
ERROR 1044 (42000):
Access denied for user 'root'@'localhost' to database
'mysql'
SELECT
host,user,password,Grant_priv,Super_priv FROM
mysql.user;
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
FLUSH PRIVILEGES;
GRANT ALL ON *.* TO 'root'@'localhost';
GRANT ALL ON *.* TO 'root'@'127.0.0.1';
GRANT ALL ON *.* TO 'root'@'xyz.xyz.com.cn';
GRANT ALL ON *.* TO 'root'@'123.123.123.123';
FLUSH PRIVILEGES;
quit
REF:
http://www.cnblogs.com/kerrycode/p/3861719.html
https://help.ubuntu.com/community/MysqlPasswordReset
http://blog.itpub.net/27099995/viewspace-1362951/
转自:http://www.cnblogs.com/emanlee/p/4621727.html

加载中…