Connection to the MySQL Database

Working MySQL database by purpose, it needs a script, which will call or query the database for necessary stored information. In this case you should connect the script in the database by a configuration file. If you don’t know where this file is located, please look at lists with different scripts to find it.

Settings of the Configuration

Scripts like Wordpress, WHMCS and Joomla are examples for database driven scripts and they usually have a default configuration file, which is ready for edit. Here is anexample, showing how will look like access information:

Host Name = localhost (literally input localhost)                            
Database Name = cpanelUsername_databaseName                  
Database Username = cpanelUsername_databaseUsername    
Database Password = whatever you selected                              


WordPress Example

Username = mike1337

Database Name = wrdp1

Database-Username = wp1

Database-User Password = eHTb7%Pxa9



// ** MySQL Settings ** //
/** The name of the database for WordPress */
define('DB_NAME', '
mike1337_wrdp1');

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

/** MySQL database password */
define('DB_PASSWORD', 'eHTb7%Pxa9');

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

We do not recommendconnection to the database by your cPanel username and password.

Some tips how to move Databases

  • If you move databases from servers, its name and username could change. Don’t forget to update this change in your script code. (You will find the database name and username in cPanel, then the MySQL).
  • Please note: If you use shared servers, you can change the database username only if the new name contains the cPanel username in it. This is due to avoiding username conflicts with others on the server.
MySQL User Has NoPrivileges

There are random bugs with the 11.25 update. Adding of IP to the MySQL access list leads to no privileges for the MySQL user.

If you want to get the correct privileges follow these steps:

1. Go to MySQL Databases in cPanel.
2. Re-add the user to each database.To do this select the user and the database from the drop-down menus.
3. Reassign all privileges.
4. Click Add.

 


Was this article helpful?

mood_bad Dislike 0
mood Like 2
visibility Views: 3052