Troubleshooting MySQL Database Connection Issues

Databases are the driving element of a Web Property. Databases tell a site property how to function on a dynamic level, meaning that the information can be smart enough to update without the user directly making those changes if need be. Without a proper connection to an SQL database, a Web Property cannot function and you will likely be met with one of the following warnings:

Error establishing a database connection


Warning: mysql_connect(): Access denied for user: 'user1_name1@localhost' (Using password: YES) in /home/joe123/public_html/ catalog/includes/functions/database.php on line 19
Unable to connect to database server!

These warnings indicate that the website database now exists in cPanel, but the website cannot communicate with it. This can be corrected by checking each of the connection points between the database and the website as detailed in the steps below.

1. Create and Assign a New Database User.

The first step is to create a new user and then assign the user to the database. This is needed to reconfigure your  Web Property's database settings.

Create a new database user.

Under Add User To Database, choose the user you just created from the User drop-down menu.
Choose the name of your database from the Database drop-down menu and click Add. (Notice that cPanel will automatically prepend your database name with your cPanel username.)
Be sure to note the database user name and user password for the new user being assigned to the database. This is very essential to the following steps.

2. Locate the Database Configuration File

Once you have created a new user and have assigned the user to the database, you will need to locate the database configuration file for the website.

If you received a general error message like the first example, please refer to the following article for help determining the location of your configuration file:

Location of Script Configuration Files

If you received a specific error message like the second example, then the location of the error has been provided. In the example above, the message indicates that the error occured "in
/home/joe123/public_html/catalog/includes/functions/database.php on line 19."

3. Reconfigure the Database Settings

Once the configuration file has been located, you can reconfigure the database settings for your website. Though every script can vary, the following instructions provide a general walkthrough of how to complete this step.

Go to the configuration file and choose to Edit.
Look in the code for a place where the database name is defined. The database information should be fairly obvious and easy to find. Here is an example of what the database for a WordPress installation would look like:
define('DB_NAME', 'user1_wrdp1');
define('DB_USER', 'user1_name1');
define('DB_PASSWORD', '5Jmfde%53L');
define('DB_HOST', 'localhost');
Make sure that the cPanel username in the first part of the database name is correct. Update the cPanel username (part before the underscore) if needed, but change nothing after the underscore. For example:
define('DB_NAME', 'joe123_wrdp1');
Replace the current DB_USER and DB_PASSWORD values in the file with the new values. For example:
define('DB_USER', 'joe123_gatorboy');
define('DB_PASSWORD', 'nvGHdCC0dCMz');
Be sure that the host name is localhost.
Save the file, and you are done!
After completing the steps above, you should no longer receive an error message regarding your database connection.
Awesome Sales & Support  (888) 600-2011
Web Hosting & Designing Firm Since 2007
Related Topics Troubleshooting Menu | What is FTP?  | Using Network Tools  | About Nameservers                                                                
Quick Links
Need Assistance With Your Database? This Article Covers Details Regarding
Why Choose Griotsites Web Hosting & Designs? Because we absolutely LOVE what we do and we're good at it too, that's why!™

What is a Griot?      What We Offer      Reviews
Educating Website Owners is our Business. Get Webucated Today!
Griot International, LLC™
Casa Grande, AZ 85122
(888) 600-2011
Ready to Get Online? Contact a Web Specialist at (888) 600-2011
Use of this web site constitutes acceptance of the Terms of Use and Privacy Policy.
GriotSites™ and Griot International™ logos are trademarks and/or registered trademarks of Griot International LLC™ in the United States and/or other countries.
GriotSites™ Copyright © 2014-18 - Problems with this site? Contact us @
Account Management
Shop Web Products
About GriotSites
Partner With GriotSites
Direct: 623.329.1911
Toll: 888.600.2011
Dont Miss the latest updates and web tips from our Virtual Web Specialists. "Like" us on Facebook, or "follow us" on twitter, Instagram, or Google Plus.
Join Us on Google Plus
Join Virtual Website Brokers on Facebook
Join Virtual Website Brokers on Instagram
Join Virtual Website Brokers on Twitter
GriotSites Web Agent
Proudly Designed by GriotSites Seal