Get the App
SLTechnology News&Howtos  ›  Database  › 

How to change root password in mysql

Shulou Source: shulou.com Published: 2022-05-31 19:25:20 10月11日 Update

Mysql how to change the root password, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Method 1:

Under / usr/local//bin/:

. / mysqladmin-u root password new_password

It is generally set up in this way during installation.

Method 2:

In the mysql state:

Mysql > UPDATE user SET password=PASSWORD (new_password) WHERE user=root

Mysql > FLUSH PRIVILEGES

Method 3:

Mysql > SET PASSWORD FOR root=PASSWORD (new_password)

Some people may ask whether it is possible to change the password if you do not know the password of mysql root. Answer: yes, if you want to know how, please read on:

Only when mysqld starts, add-- skip-grant-tables to ok.

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-A

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)

After reading the above, have you mastered how to change the root password in mysql? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Password method content more problem helpless for this reason only for this situation skill time this method status answer article experience industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple OPPO Reno Xiaomi vpn macOS