How to change the database user password – cPanel?

Changing the database user password using bash script?

Change the database user password, need simple solution!!

The MySQL community has depreciated “old_passwords” option since MySQL 5.6 version.

So we won’t be able to recollect the password from an old password hashing format.

So, once we upgrade the MySQL server version to 5.6 (or above) we can not reuse the MySQL user passwords which are still using old password technique (old hash format).

What are password hashes?

It is insecure to store plain text passwords in the password database.

We (new technology hackers :P) can simply recreate those old hashed password simply using their tools. So, since 5.6 MySQL strictly depreciated the old_password option to use the old format password.

Once, we upgrade the MySQL version in server, the websites using old password hash will not work. The site through db connection error.

Error Establishing a Database Connection

You can fix this error simply by updating the database user password with its current password. You will get the password details from its configuration file.

How to create a New Database-user and Grand Permissions – MySQL

We already discussed about the creation of MySQL DB and DB users. Here I am explaining the commands which are using to Grand Privileges to users for accessing the Databases in your server.

Enter the mysql prompt by following the step below:

# mysql -u root -p

It then prompts for password. Enter the MySQL root password.

Read more…

How to change the database user password from cPanel?

This is really simple. Please do the following steps:

1. Log into cPanel.

2. Click on “MySQL databases” under databases tab.

How to change the database user password?
How to change the database user password?

3. Scroll down. There is an option to change db user password.

How to change the database user password?
How to change the database user password?

Yeah.. change/update the database user password from here.. That’s it!!

How to change the database user password using bash script? If you have a lot of db users and a lot of websites on your server, please try the following bash script to change the database user password. This should be helpful to save a lot of time.

I wrote this simple bash script to find out and update the db user password from Linux command line. I am not a super coder 😛 However, you can trust me, I tested this on my site in live environment. Simply do the following steps.. Read more…

Just create an executable file and paste the code into it and execute, explore!!!

#!/bin/sh
echo "This script is useful for only commonly using CMSs like WP, Joomla, Drupal, Magento, Drupal etc with known configuration location. If nothing listing and you are getting db conntction error check configuration manually.. Thanks by Arunlal"
echo "" > details.txt
echo "Please enter the cPanel username: "
read username
grep -irl ${username}_ /home/$username/*{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php /home/$username/*/{wp-config,configuration,config,global.inc,db-config,config.properties,configure,mysql.class,Settings}.php /home/$username/*/*/{wp-config,configuration,config,global.inc,db-config,config.properties.......
CHECK FULL CODE FROM HERE.....

Git it : https://gist.github.com/ashokarun/8c6cbae2266dc03a5d600700b0d2d6f5

That’s it buddies!

, ,

Post navigation

Arunlal Ashok

Linux Systems Architect at Endurance International Group. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com

2 thoughts on “How to change the database user password – cPanel?

Leave a Reply

Your email address will not be published. Required fields are marked *