Clear MySQL password under RHELorFedora

Source: Internet
Author: User
1. log on to the system as a root user. 2. Disable the MySQL service or process: servicemysqldstopkillallmysqld. 3. Enable the MySQL: usrlocalmysqlbin privilege.

1. log on to the system as a root user. 2. Disable the MySQL service or process: service mysqld stop/killall mysqld. 3. Start MySQL:/usr/local/mysql/bin with the privilege.

1. log on to the system as the root user first;

2. Shut down the MySQL service or process: service mysqld stop/killall mysqld;

3. privileged to start MySQL:/usr/local/mysql/bin/mysqld_safe -- skip-grant-tables & or mysqld_safe -- skip-grant-tables -- skip-networking & (note: parameter -- skip-grant-tables indicates that the authorization table is skipped; -- skip-networking indicates that TCP/IP connections are not monitored );

4. Then, you can enter MySQL: mysql-u root-p without a password (you can press enter directly when entering the password );

Mysql> use mysql;

Mysql> update user set password = password ('new pw ') where user = 'root' (Note: 'New pw' is your new password, others are copied;

Another method: update mysql. user set password = password ('new pw ') where user = 'root ';

5. Update:

Mysql> flush privileges;

Mysql> quit;

6. End the newly started MYSQL process: killall mysqld or killall-9 mysqld.

7. start MYSQL normally: service mysql start

8. log on to mysql-u root-p with 'new pw.

OK ......

> You can also do the following:

First, modify the MySQL Logon Settings:
# Vi/etc/my. cnf
In the [mysqld] section, add skip-grant-tables.
For example:
[Mysqld]
Datadir =/var/lib/mysql
Socket =/var/lib/mysql. sock
Skip-grant-tables
Save and exit vi.

Restart mysqld and change the password;

Finally, modify the MySQL Logon Settings:
# Vi/etc/my. cnf
Delete the skip-grant-tables added to the [mysqld] section.
Save and exit vi.

Log on to MySQL again, just like OK ......

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.