How to change the mysql root Password

Source: Internet
Author: User

Method 1:
Under/usr/local/mysql/bin:
./Mysqladmin-u root password new_password
This method is usually used for installation.

Method 2:
In mysql:
Mysql> UPDATE user SET password = PASSWORD (new_password) WHERE user = root;
Mysql> flush privileges;

Method 3:
Mysql> set password for root = PASSWORD (new_password );

Someone may ask if I don't know the mysql root Password, can I change it? Answer: Yes. If you want to know the method, proceed with the following:

You can only add -- skip-grant-tables when mysqld is started,

Example:

[Root @ server] #/usr/local/mysql/bin/mysqld_safe -- skip-grant-tables &

[Root @ server] #/usr/local/mysql/bin/mysql-uroot-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 7
Server version: 5.0.45-log Source distribution

Type help; or h for help. Type c to clear the buffer.

Mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-

Database changed
Mysql> update user set password = password (******) where user = root;
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0

Mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

Kill the mysql process or restart mysql, and then log on again. The password takes effect.

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.