I am a beginner and I have two servers. One is Debian based and one is CentOS based.
I tried lots of methods (listed below) and from other websites but I didn't find how to change the root password of MySQL or even to find out the root username.
How can I do this for both servers?
Related questions which not helped me:
1. FIND ROOT USERNAME
The root username is always
root
.2. HOW TO CHANGE DEFAULT ROOT PASSWORD
Connect to your server using console And then:
Stop MySQL
If you are using Ubuntu or Debian:
For CentOS, Fedora, and RHEL:
Start MySQL in safe mode
Login (without any password)
Select the database
Change password
Flush Privileges (like refresh)
Exit
or
Restart MySQL Ubuntu and Debian
and
CentOS, Fedora and RHEL
and
Password changed successfully!
Now, you can try to login with the new password:
(type the password when prompted)
Hope this helps!