VestaCP – How to find default MySQL Root Password and Change it
When we install VestaCP MySQL root password is different then our VPS root password. VestaCP generate MySQL root password randomly and stored at mysql.conf file.
Where is your VestaCP MySQL root password stored?
The password is stored at:
/usr/local/vesta/conf/mysql.conf
Check the password:
nano /usr/local/vesta/conf/mysql.conf
How to change the VestaCP MySQL root password?
Step 1 – Use this usual mysql command to change password:
mysqladmin -u root -p OLDPASSWORD password 'NEWPASSWORD'
Replace OLDPASSWORD with the real mysql root password you get from mysql.conf file above. Also replace NEWPASSWORD with the new password you wish, just make sure you can remember it or noted in down.
Step 2 – Once done, try login back to mysql server as root using the new password you’ve just defined:
mysql -u root -p NEWPASSWORD
Step 3 – Open up mysql.conf file once again and replace your old password (the one generated by Vesta) with your new password:
nano /usr/local/vesta/conf/mysql.conf
Save changes and exit the editor which in Nano it is Control+O then Control+X.
Step 4 – Next, you have to change old mysql password stored in my.cnf:
nano /root/.my.cnf
Replace that with the one you defined in step 1.
That’s all.