我刚刚在CentOS机器上使用安装了Mysql yum.安装没有错误.然后我按照这些步骤:
$ 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):
Run Code Online (Sandbox Code Playgroud)
可以看出,即使在首次安装之后,登录到DB也存在问题.我甚至尝试过所有命令sudo,但错误仍然存在.我甚至无法弄清楚如何重新配置MySQL.我已经安装了3次删除mysql.
我该如何解决这个问题?
Sub*_*Red 30
适用于在MySQL 5.7上遇到此问题的任何人.或更高.
MySQL v 5.7或更高版本在安装后生成临时随机密码并存储在mysql错误日志文件中,该文件位于/var/log/mysqld.log
CentOS 7上的MySQL Yum存储库进行安装.
使用下面的命令来查看密码:
sudo grep 'temporary password' /var/log/mysqld.log
Run Code Online (Sandbox Code Playgroud)
参考:MySQL 5.7.7 - Centos 7 el7 - 访问被拒绝
EDIT1
对于任何人都有不同的错误日志文件,您可以使用@德鲁的答案找到它这里下面.
也许您已经在某个时候设置了它。你可以试试这个:
yum remove mysql-server
rm -rf /var/lib/mysql
yum install mysql-server
systemctl start mysqld.service
/usr/bin/mysql_secure_installation
Run Code Online (Sandbox Code Playgroud)
不管怎样,我认为这个问题应该在ServerFault中。