Reset MySQL Password in WSL
insights Stats
warning Please login first to view stats information.
Kontext
SQL Databases
SQL relational databases incl. SQLite, SQL Server, MySQL, PostgreSQL, Oracle, etc.
When MySQL was installed on WSL (Install MySQL on WSL), by default, we can use command sudo mysql
to start MySQL CLI without the need to input the password.
Reset root user password
Run the following command to start mysql CLI:
sudo mysql
And then run the following SQL statement to change password:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
The above statement changes password to 'root'.
Reset other user's password
Similarly, run the following command to change other user's password:
mysql> ALTER USER 'user'@'localhost' IDENTIFIED BY 'newpassword';
Reset root password using init file
Another approach is to created a init file named '
mysql-init
' in user home folder with the following statement:ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
And then stop or kill mysqld
and run the following command:
sudo mysqld --init-file=/home/username/mysql-init &
Remember to change the file path accordingly.
copyright
This page is subject to Site terms.
comment Comments
No comments yet.