Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to reset root password for MySQL  (Read 2167 times)

0 Members and 1 Guest are viewing this topic.

Yazar khader

  • Guest
How to reset root password for MySQL
« on: December 21, 2013, 06:37:47 pm »
You can view the MySQL root password in the file /root/.my.cnf.
# cat /root/.my.cnf
[client]
pass="sdd568c~M"
user=root
Want to reset the root password for MySQL? Follow the below steps.
1. Stop mysql
2. Create a text file(for eg: /home/mysql-init) and place the following statements in it. Replace the password with the password that you want to use.
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'
FLUSH PRIVILEGES;
3. Execute the following command
mysqld_safe --init-file=/home/mysql-init &
4. Remove /home/mysql-init, kill mysql and start mysql.