简体   繁体   English

访问被拒绝用户'root'@'localhost'(使用密码:NO) - 出了什么问题?

[英]Access denied for user 'root'@'localhost' (using password: NO) - what's wrong?

(Sorry for my English) (对不起我的英语不好)

This is a log of my console: 这是我的控制台的日志:

anton@anton-X451CA:~$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
anton@anton-X451CA:~$ mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

What should I do? 我该怎么办? I understand that it appears when I try entering without a password, but I am dont confirmed password, and 'root'/empty string doesn't help. 据我所知,当我尝试输入时没有密码,但我没有确认密码,'root'/空字符串没有用。

I solved the problem, when: 我解决了这个问题,时间:

Change the file my.cnf (in my Ubuntu-system he is placed at /etc/mysql/my.cnf). 更改文件my.cnf(在我的Ubuntu系统中,他位于/etc/mysql/my.cnf)。 In the end i added that code: 最后,我添加了该代码:

[mysqld]
skip-grant-tables

That's helps enter in condole as anyone user without pass. 这有助于在没有通过任何用户的情况下进入吊.. Restart the server: sudo service mysql restart 重启服务器:sudo service mysql restart

Enter in the mysql-console: 在mysql-console中输入:

mysql -u root

Change the password for user root: 更改root用户的密码:

UPDATE mysql.user SET authentication_string=PASSWORD('root'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';FLUSH PRIVILEGES;

exit the console: 退出控制台:

\q

Remove (or use commentary) for that in my.cnf (we dont need that settings now): 在my.cnf中删除(或使用评论)(我们现在不需要这些设置):

#[mysqld]
#skip-grant-tables

restart mysql-server: 重启mysql-server:

sudo service mysql restart

That's all. 就这样。 :) :)

When you installed this fresh, you usually execute 安装新的时,通常会执行

mysql_secure_installation

afterwards. 然后。 There you also set the initial password for your root account (note, that this is not the root account you have in Linux). 您还可以在其中设置root帐户的初始密码(请注意,这不是您在Linux中拥有的root帐户)。

When you installed version 5.7. 安装5.7版时。 or higher the initial password is not blank anymore. 或更高的初始密码不再是空白。 You can find it in the error log. 您可以在错误日志中找到它。 Find this log by looking in your my.cnf file. 通过查看my.cnf文件查找此日志。 Default directory is /var/log/mysql , I think. 我想默认目录是/var/log/mysql

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用密码:用户“ root” @“ localhost”的访问被拒绝 - Access denied for user 'root'@'localhost' using password: NO 用户'root'@'localhost'的访问被拒绝(使用密码:NO) - Access denied for user 'root'@'localhost' (using password: NO) '访问被拒绝用户'root'@'localhost'(使用密码:NO)' - 'Access denied for user 'root'@'localhost' (using password: NO)' 用户'root'@'localhost'访问被拒绝(使用密码:NO); - Access denied for user 'root'@'localhost' (using password: NO); 拒绝用户 'root'@'localhost' 访问(使用密码:YES)或(使用密码:NO)? - Access Denied for User 'root'@'localhost' (using password: YES) or (using password: NO)? 使用MAMP拒绝用户'root'@'localhost'的访问(使用密码:是) - Access denied for user 'root'@'localhost' (using password: YES) using MAMP 避免“拒绝访问用户 'root'@'localhost'(使用密码:NO)” - Avoid 'Access denied for user 'root'@'localhost' (using password: NO)' NetBeans 表示用户 'root'@'localhost' 的访问被拒绝(使用密码:YES) - NetBeans says that Access denied for user 'root'@'localhost' (using password: YES) MySQL:用户'root @ localhost'的访问被拒绝(使用密码:NO) - MySQL: Access denied for user 'root@localhost' (using password:NO) 用户'root'@'localhost'的访问被拒绝(使用密码:是) - Access denied for user 'root'@'localhost' (using password: YES)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM