Home  >  Article  >  Database  >  How to Remove the Password for the Root User in MySQL?

How to Remove the Password for the Root User in MySQL?

Susan Sarandon
Susan SarandonOriginal
2024-10-30 11:11:56699browse

How to Remove the Password for the Root User in MySQL?

Resetting MySQL Root Password to Null

Q: How do I remove the password for the root user in MySQL via the command line interface?

A: To set the root user's password to null (i.e., no password), follow these steps in the MySQL command line client:

<code class="sql">use mysql;
update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';</code>

In case the 'plugin' field is set to 'auth_socket,' you may also need to change it along with the password:

<code class="sql">use mysql;
update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';</code>

Once these updates are complete, you will be able to connect as the root user without providing a password by simply running the command:

<code class="sql">mysql -u root</code>

The above is the detailed content of How to Remove the Password for the Root User in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn