All articles, Linux server, Web Hosting Tools and Techniques

Resetting root password in MySQL

Resetting root password in MySQL

To change the password for the MySQL database user root, you need to connect to the server via SSH (we recommend using the SSH client PuTTY).

First, stop MySQL with the following command:

# service mysql stop (the service might also be named mysqld)

Start MySQL with special privileges:

# mysqld_safe –skip-grant-tables &

Launch the root client:

# mysql -u root

Resetting root password in MySQL mysql1

Next, execute an SQL query to change the password for the root user:

# update user set password=PASSWORD(“newpassword”) where User=’root’;

Replace newpassword with the new password you want to set.

Apply the changes:

# FLUSH PRIVILEGES;

You can now exit the MySQL client with the exit command and restart the MySQL server itself:

# service mysql restart

Resetting root password in MySQL mysql2