How To Change The MYSQL Root Password
You can change the MySQL password for the root user at any time by using an SSH console. The following guides details how this is achieved on CentOS, RedHat, Fedora, Debian and Ubuntu.
First, stop the existing MySQL service by using the following commands
For CentOS, RedHat and Fedora Servers
service mysqld stop
For Debian and Ubuntu Servers
service mysql stop
Next, you need to restart the MySQL service with the —skip-grant-tables option using the following command
mysqld_safe --skip-grant-tables &
Running MYSQL with the —skip-grant-tables is extremely insecure. Only do this for brief periods of time and only when absolutely necessary. The following steps will start MySQL in the usual way without this option loaded.
Now, log into MySQL with the following command
mysql
Use the below command to set a new root password for MySQL. Replace NEW-PASSWORD with your new Mysql password.
UPDATE mysql.user SET Password=PASSWORD('NEW-PASSWORD') WHERE User='root';
Then issue the below command
FLUSH PRIVILEGES; exit;
Next, stop the MySQL service. You will be asked for your new MySQL root password at this point
mysqladmin -u root -p shutdown
Finally, start the MySQL service in the normal way
For CentOS, RedHat and Fedora Servers
service mysqld start
For Debian and Ubuntu Servers
service mysql start
You have now updated your MySQL root password. Ensure you keep a secure copy of your MySQL root password or you may need to change it again. For details on installing MYSQL, PHP and Apache on CentOS6 you can use this guide
How was this article? – Change The MYSQL Root Password
You might also like
More from All About Linux
How to install FTP and configure FTP on an Ubuntu 22 LTS instance
If you need to upload files to your NVMe VPS you have a couple of options. You can use a …
How to install a Cloudflare Origin SSL Certificate – NGINX
An SSL Certificate is vital to encrypt data between you and your clients. SSLs can be complicated things. If they …
How To Open Port FirewallD and Close Port FirewallD -CentOS 7
Open And Close Ports In FirewallD - Manage Zones In FirewallD Like IPtables, FirewallD is a Linux firewall that filters packets …