ERROR - CANNOT CONNECT TO MYSQL DATABASE

One of the most common errors when working with MySQL databases is when you receive the 'cannot connect to database' error. Before you submit a ticket check to ensure you have done the following:

For the server name you should put in:

localhost

(If the database is on the same server as the site requesting the database).

Another couple of items to check is to make sure you have created a user which is assigned to the database (see here). To access a database you need to create a user which has permission to access the database. If you have not done this you cannot connect to the database.

Next, check to make sure that you have the user name correct in your script as well as the database name. The way the server works is that it prefixs the login of the account to the beginning of every database user and database. It does this so there is not a conflict between databases of the same name across the server. So if your login for the account is "fred" and you created a database named "flintstone" the official name of the database is:

fred_flintstone

You would need to reference the database exactly like this in your scripts or config files.

The same goes for a user. If the database user is "wilma" then in the config file you would list the user as:

fred_wilma

These are the most common errors.

Please click here for full step-by-step instructions on how to setup a database and user.