assistanz
Assistanz

Error Establishing a Database Connection in WordPress – Cpanel Server

cPanel Server Management 

For 24×7 cPanel Server Management with Monitoring, Unlimited Tech Support, Disaster Recovery, Security updates and much more Signup today! 

Error Establishing a Database Connection in WordPress – cPanel

In this blog, we will show you the steps to resolve the Error Establishing a Database Connection in WordPress – cPanel Server

The domain is hosted in the cPanel server and faced the below-mentioned database error. By following our suggested solutions, we may resolve the database connection problems.

Error Establishing a Database Connection in WordPress - Cpanel Server

Step 1:-

  • Login to the SSH goes to the Cpanel domain document path ” /home/<user-name>/public_html/”
  • Open the wp-config.php and check your WordPress database credentials

– WordPress needs the following information for connecting to the database:

Error Establishing a Database Connection in WordPress - Cpanel Server

  • Database name
  • Database username
  • Database password
  • Database server

You need to make sure that the information for the database name, username, password, and database host is correct. 

Step 2:-

Check the user User Privileges

  • Login into your Cpanel hosting account

Error Establishing a Database Connection in WordPress - Cpanel Server

  • Click on MySQL databases under the database section.

Error Establishing a Database Connection in WordPress - Cpanel Server

  • This will take you to the Cpanel database management page in your hosting dashboard. From here, you can find out your database name and username.

Error Establishing a Database Connection in WordPress - Cpanel Server

  • Select the user name and database name under the “User To Database” Press “Add” It will redirect to screen 2.

Error Establishing a Database Connection in WordPress - Cpanel Server

  • You can select the check box ALL PRIVILEGES and click the button Make Changes. It will assign the database privileges to all the databases.

Error Establishing a Database Connection in WordPress - Cpanel Server

https://docs.cpanel.net/whm/sql-services/manage-mysql-profiles/88/

Step 3:

We had an experience with CloudLinux & CageFs, there is yet another way to fix the Cpanel server’s database connectivity issue. Please do the following.

  • You can find the CageFs in the WHM by Searching for CageFs

Error Establishing a Database Connection in WordPress - Cpanel Server

  • Find the domain or UserName in the CageFS.

Error Establishing a Database Connection in WordPress - Cpanel Server

  • If the domain or UserName exists in the CageFs then try removing it from CageFs and check the website.

Error Establishing a Database Connection in WordPress - Cpanel Server

  • Add the Domain or UserName back to the CageFs. 

Error Establishing a Database Connection in WordPress - Cpanel Server

step 4:

On troubleshooting the log related to Cpanel WordPress database connectivity. You can check the logs the error log for the domain:

# tailf /home/username/public_html/error_log

Error Establishing a Database Connection in WordPress - Cpanel Server

# tailf /usr/local/apache/error_log

Error Establishing a Database Connection in WordPress - Cpanel Server

# tailf /usr/local/apache/log/error_log

Here is a sample error that we have faced during troubleshooting:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[20:47:35 UTC] PHP Warning: PHP Startup: Unable to load dynamic library '/opt/cpanel/ea-php56/root/usr/lib64/php/modules/pdo_mysql.so' - /opt/cpanel/ea-php56/root/usr/lib64/php/modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[20:47:35 UTC] PHP Warning: PHP Startup: Unable to load dynamic library '/opt/cpanel/ea-php56/root/usr/lib64/php/modules/sqlite.so' - /opt/cpanel/ea-php56/root/usr/lib64/php/modules/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
[ 20:47:35 UTC] PHP Warning: Module 'PDO' already loaded in Unknown on line 0
[ 20:47:35 UTC] PHP Warning: Module 'pdo_sqlite' already loaded in Unknown on line 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note: This error is caused by the MySQL extension being disabled on your hosting account. In order to enable it, please do the following steps.

  • Log in to your cPanel account.
  • Look for the option “Select PHP Version” & click on it.
  • Once there, change the PHP version to Current from the dropdown as shown below.
  • Once you have selected the PHP version as current, tick on the option that says pdo, pdo_sqlite, SQLite, pdo_mysql, “mysqli” and/or “mysqlnd” from the options presented and click save.

Step 5:

You will need to enable and install the MySQL PHP extension using the EasyApache 4 interface in your WHM.

  • Log into your WHM as root.
  • Search for the option “EasyApache 4” & click on it.
  • You will see a highlighted box “Currently Installed Packages”, click on the ‘customize’ button.
  • Once there, select ‘PHP Extensions’ and in the search box type MySQL, you will see the mysqlnd options.
  • Select the required mysqlnd extension as per your requirement of the PHP versions. You can simply select all the version that is displayed, this will cause no problems.
  • Once you have selected the mysqlnd extensions there click on “Review”, scroll down and click on the “Provision” button.
  • Once finished, click on done and check your WordPress installation and the error should be gone.

To check the modules are installed on the server you can use below command

# php -m

cPanel Server Management 

Assistanz is a pioneer in offering 24×7 cPanel Server Management Service since 2004.

We offer 24×7 cPanel Server Management

  • cPanel Server Management
  • cPanel Installation and Setup
  • cPanel Server Optimization
  • cPanel Server Migration
  • cPanel Server Security and Hardering
  • cPanel Server Monitoring
  • cPanel Server Hack Recovery

and Much more

DirectAdmin Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk
$ 99 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • NDA & SLA
  • SLA Review Meetings
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation
  •  

Platinum Support

24/7 Proactive Support
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Support

$ 30 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response Time
  • 4 Hours Resolution time for the Possible Issues
  • Security and Performance Optimization
  • React to Customers queries
  • Simple SignUp Process
  • Instant Account Activation
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support