Assigning a Null Password to the MySQL Root User
The root user is the administrator of a MySQL database. By default, the root user has a password that secures the database from unauthorized access. However, if you need to remove the root user's password, you can do so using the MySQL command line client.
Solution:
To set the root user's password to null, follow these steps:
Connect to the database as the root user. For example:
$ mysql -u root
Run the following query:
use mysql; update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';
Note:
If the 'plugin' field is set to 'auth_socket', you may need to change it to 'mysql_native_password' for the query to work.
Verification:
Once the query has been executed, you can try logging in as the root user without a password:
$ mysql -u root
If you can log in successfully, then the root user's password has been removed.
The above is the detailed content of How to Remove the Password from the MySQL Root User?. For more information, please follow other related articles on the PHP Chinese website!