Centos solves mysql connection ERROR 1045 (28000) first stop mysql service # service mysql stop next execute # mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking & but if no environment variable is configured, the system prompts that the mysqld_safe command cannot be found. Therefore, you can only find the mysql installation directory and enter the bin directory. The command is in the current directory, therefore, execute this command in the current directory and then execute # mysql-u root mysql www.2cto.com with a blank password, log on to mysql and change the root Password mysql> UPDATE user set password = Password ('newpassword') where USER = 'root' and host = 'root' or host = 'localhos T'; next, change all empty user passwords to non-empty passwords. mysql> flush privileges; www.2cto.com, and exit mysql. Mysql> quit restart mysql service # service mysql restart log on to mysql with a new password # mysql-uroot-p Enter password: <Enter the new password newpassword>