Mysql5.7 how to change the root password _ MySQL

Source: Internet
Author: User
Changing the password of the administrator root in mysql is a very common problem. There are also many tutorials on the internet. However, the new version of MYSQL5.7 can use the previous tutorials, I found the modification method. here I will share it with you. Version Update. the password field in the original user has been changed to authentication_string

Because of version updates, many online tutorials are not applicable, and even the documents on the official website cannot be operated smoothly.

If MySQL is running, first:


killall -TERM mysqld。


Run


mysqld_safe --skip-grant-tables &


If you do not want to be remotely connected at this time:


mysqld_safe --skip-grant-tables --skip-networking &


Connect to the server using mysql

Change password:


update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';


* Note that the Password field is no longer in the user table of the new mysql database.

Instead, the encrypted user password is stored in the authentication_string field.


mysql> flush privileges;mysql> quit;


Modification completed. Restart


killall -TERM mysqld。mysqld_safe &


Then mysql can be connected.

However, at this time, the operation seems to be not fully functional, but also alter user...


alter user 'root'@'localhost' identified by '123';


The net says that the sauce purple can also:

set password for 'root'@'localhost'=password('123');cp mysql.server /etc/init.d/mysqlchmod +x /etc/init.d/mysqlchkconfig --add mysql


The above is how to change the root password _ MySQL in Mysql5.7. For more information, see PHP Chinese network (www.php1.cn )!

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.