mysql_ERROR 1045 (28000): Access denied for user ‘xxx’@’xxx’解决

#1 -> su - root    
#1 -> /etc/init.d/mysqld stop
#1 -> mysqld_safe --skip-grant-tables &
#2 -> mysql -uroot -p密码 -h127.0.0.1 
#或者
#2 -> mysql -uroot -p密码 -h127.0.0.1 --protocol=tcp
#1和2任选一种方式登陆
>use mysql;
>select host,user from mysql.user;
#删除host为%和127.0.0.1的用户
#>DROP USER 'train'@'%';
#>DROP USER 'train'@'127.0.0.1'
>CREATE USER 'train'@'localhost' IDENTIFIED BY '123456'; #注意添加新用户时需要填写如'train'@'localhost'而不是train就可以的
>flush privileges;
>quit;
#1 -> jobs
#1 -> service mysqld stop
#1 -> kill %1
#1 -> service mysqld start
mysql -u用户名 -p密码

成功解决,因为mysql默认登陆方式为localhost但是一旦出现%的host,mysql会默认用%作为host的方式登陆如root@%,所以无法登陆。

此条目发表在Linux分类目录。将固定链接加入收藏夹。

发表评论

邮箱地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Protected with IP Blacklist CloudIP Blacklist Cloud