拒绝用户“root @ localhost”的访问(使用密码:YES)

Cent OS中安装MySQL时,它被正确安装。

安装完成后,我在terminalinput这个命令。

/etc/init.d/mysqld start 

它显示错误,我input密码为“新密码” 。 在这个时候,我发现这个错误。

 [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) 

安装完MySQL之后,你需要运行mysqladmin来设置root密码。

 mysqladmin -u root password NEWPASSWORD