在Centos上第一次运行Mysql时访问被拒绝 [英] Access denied while running Mysql for the first time on Centos
问题描述
我刚刚使用 yum
在CentOS机器上第一次安装了Mysql。安装没有错误。然后我按照这些步骤:
$ sudo / sbin / service mysqld start --skip-grant-tables --skip-networking
pre>
$ sudo / usr / bin / mysql_secure_installation
注意:建议为所有MySQL运行此脚本的所有部分
生产中使用服务器!请仔细阅读每个步骤!
为了登录MySQL以保护它,我们需要root用户的当前
密码。如果你刚刚安装了MySQL和
,你还没有设置root密码,密码将为空白,
,所以你应该在这里输入。
输入root的当前密码(不输入):
错误1045(28000):访问被拒绝用户'root'@'localhost'(使用密码:NO)
输入root的当前密码(无输入):
错误1045(28000):拒绝用户'root'@'localhost'的访问(使用密码:NO)
输入root的当前密码none):
错误1045(28000):访问被拒绝用户'root'@'localhost'(使用密码:NO)
输入root的当前密码(不输入):
ERROR 1045(28000):拒绝用户'root'@'localhost'的访问(使用密码:NO)
输入root的当前密码(输入none):
可以看出,即使在第一次安装后,登录数据库也有问题。我甚至尝试所有命令在
sudo
,但错误仍然存在。我甚至不知道如何重新配置MySQL。
我如何解决这个问题?
解决方案也许你已经在某个时刻设置了它。您可以尝试:
yum remove mysql-server
rm -rf / var / lib / mysql
yum install mysql-server
systemctl start mysqld.service
/ usr / bin / mysql_secure_installation
$ b b反正,我认为这个问题应该在ServerFault。
I just installed Mysql for the first time on a CentOS machine using
yum
. The installation had no errors. Then I followed those steps:$ sudo /sbin/service mysqld start --skip-grant-tables --skip-networking $ sudo /usr/bin/mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) Enter current password for root (enter for none):
It can be seen that even after first installation there is issue in logging in to the DB. I have even tried all command in
sudo
, but the error is still there. I can't even figure out how to reconfigure MySQL. I halso have installed-removed mysql 3 times.How can I solve this issue?
解决方案Maybe you already setted it at some point. You can try this:
yum remove mysql-server rm -rf /var/lib/mysql yum install mysql-server systemctl start mysqld.service /usr/bin/mysql_secure_installation
Anyway, I think this question should be in ServerFault.
这篇关于在Centos上第一次运行Mysql时访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!