) How to change/modify the root password in MySQL

Source: Internet
Author: User

1. Edit the MySQL configuration file:

In Windows: % mysql_installdir %/My. ini // In the MySQL installation directory, my. INI is the configuration file of MySQL.
In Linux:/etc/My. CNF

Add the following line in the [mysqld] configuration section:
Skip-grant-tables

Save and exit editing.

2. Restart the MySQL service.

In Windows:
Net stop MySQL
Net start MySQL

In Linux:
/Etc/init. d/mysqld restart

3. Set a new root password.

Then run the following command in the command line:
Mysql-uroot-P MySQL
Press enter to enter the database without a password.

Run the following statement to update the root password to 123456:
Update user SET Password = PASSWORD ("123456") where user = 'root ';

Quit exits MySQL.

4. Restore the configuration file and restart the service.

Then, modify the MySQL configuration file and delete the row that you just added.

Restart the MySQL service again and the password is changed.
 

First: mysql> Update user SET Password = PASSWORD ('new _ password') where user = 'root ';
Mysql> flush privileges;

Second:
Mysql> set password for root = PASSWORD ('new _ password ');
Third:
Shell> mysqladmin-u Root Password new_password;
 

Information from: China self-learning Network (www. cnzixue. com) detailed source reference: http://www.cnzixue.com/html/web/DataBase/2009/1107/3526.html

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.