在 Cent OS 中安装 MySQL 时,它已正确安装。
安装完成后,我在终端输入此命令。
/etc/init.d/mysqld start
显示错误,我输入密码为'new-password'。在这个时候,我发现了这个错误。
[root@datsvr018 bin]# /etc/init.d/mysqld start
Starting mysqld: [ OK ]
[root@datsvr018 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: YES)
答案 0 :(得分:1)
安装MySQL后,您需要运行mysqladmin
来设置root密码。
mysqladmin -u root password NEWPASSWORD