How to connect to a MySQL database

To connect to your MySQL database from your scripts you need to enter the details of your MySQL database as follows:

Host = localhost (this is exactly what you type "localhost")

The Database Name, Username and Password are the same that you defined when creating the database as follows:

Database name = (cPanel Username_Database Name)
Database username = (cPanel Username_Database Username)
Database password = (User Password)

Using the WordPress wp-config.php file as an example for a user with cPanel Username = fred641 , Database Name = blog1 , Database Username = blogger1 , User Password =Rs$mn7q@ you would enter the following information:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'fred641_blog1');

/** MySQL database username */
define('DB_USER', 'fred641_blogger1');

/** MySQL database password */
define('DB_PASSWORD', 'Rs$mn7q@');

/** MySQL hostname */
define('DB_HOST', 'localhost');

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Do you allow remote connections to MySQL databases?

Yes, you can allow remote access to specific hosts. Select the "Remote MySQL" icon under the...

Is there a limit to the size of a MySQL database?

No. We do not specifically limit the size of any of your MySQL databases. However, the size of...

Quick Shortcuts User Guide

Once you login to your Client Area you are greeted with an account summary home page. If you...

Powered by WHMCompleteSolution