www.netcreator.us
NETCreator - News, Scripts, Hosting, CMS, Tutorials

MySQL: How to change root password? Debian, Ubuntu, Fedora, CentOS

Server & Network Configuration - NETCreator - 2016-04-05 09:28:37

1. FIND ROOT USERNAME
The root username is always root.

2. HOW TO CHANGE DEFAULT ROOT PASSWORD
Connect to your server as administrator (Check here how to do this) and then do the steps bellow:

 - Stop MySQL:

If you are using Ubuntu or Debian:
sudo /etc/init.d/mysql stop

For CentOS, Fedora, and RHEL:
sudo /etc/init.d/mysqld stop



- Start MySQL in safe mode:
sudo mysqld_safe --skip-grant-tables &

- Login (without any password):
mysql -u root

- Select the database:
use mysql;

- Change password:
update user set password=PASSWORD("YOUR NEW PASSWORD HERE") where User='root';

- Flush Privileges (a refresh for privileges):
flush privileges;

- Exit:

quit
or
exit



- Restart MySQL:

Ubuntu and Debian:
sudo /etc/init.d/mysql stop
and
sudo /etc/init.d/mysql start
CentOS, Fedora and RHEL:
sudo /etc/init.d/mysqld stop
and
sudo /etc/init.d/mysql start
Password changed successfully!

Now, you can try to login with the new password:
mysql -u root -p
(type the password when prompted)

Success!
Latest Posts
NETCreator CMS

Search
Free Hosting