If you cannot log on to mysql5.7 using rpm in centos7, centos7mysql5.7

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.