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');