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

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

Susan Sarandon
Release: 2024-10-30 11:11:56
Original
805 people have browsed it

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template