If you cannot log on to mysql5.7 using rpm in centos7, centos7mysql5.7
Recently, the latest mysql-server 5.7 (mysql57-community-release-el7-7.noarch.rpm) version was installed in centos7 using rpm, and root login was not available after installation was successful. Baidu and google failed to find the answer in the official document. Now we have recorded the complete installation and troubleshooting process, hoping to help other friends. OS version: Linux version 3.10.0-327. el7.x86 _ 64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) #1 SMP Thu Nov 19 22:10:57 UTC 2015 RPM installation of mysql-server is as follows:$ Su root$ Sudo wget http://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpm$ Sudo rpm-ivh mysql57-community-release-el7-7.noarch.rpm$ Sudo yum install mysql-server # Prompt for successful installation after yes So far, mysql57 has been successfully installed. Now try to log on to mysql using root, and the ERROR code "ERROR 1045 (28000)" is displayed ): access denied for user 'root' @ 'localhost' this problem occurs probably because mysql uses the default password to initialize the root user after rpm installation. The solution obtained by Du Niang Google is invalid for version 5.7.x. I found some ideas on the official website. After many tests, I finally solved the root login problem. The solution is as follows:$ Sudo systemctl stop mysqld. service$ Sudo systemctl set-environment MYSQLD_OPTS = "-- user = mysql -- skip-grant-tables -- skip-networking"$ Sudo systemctl start mysqld. service$ Mysql-u root mysql Mysql> UPDATE mysql. user SET authentication_string = PASSWORD ("abcdef") WHERE user = 'root' and host = 'localhost ';Mysql> flush privileges;Mysql> quit $ Sudo systemctl unset-environment MYSQLD_OPTS$ Sudo systemctl restart mysqld. serviceOK. After performing the preceding steps, you can use the root account to log on again.