HostGator.com » Support Portal



How to Connect to the MySQL Database

Configuration Settings:

Host name = localhost (literally put localhost)
Database name = (cpanelUsername_databaseName)
Database username = (cpanelUsername_databaseUsername)
Database password = (whatever you picked)

WordPress Example: User name = joe1337 , Database name = wrdp1 , Database-user name = wp1 , Database-user password = eHTb7%Pxa9

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

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

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

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

Note: When you move databases to our servers, the database name and username may change. This change must be updated in your script code. (The database name and username is clearly displayed in cPanel, in the MySQL area.)

On shared servers, the database user name cannot be changed to something without the cPanel user name in it.

It is possible for someone to use their cPanel username and password to connect to the database. However, we NEVER recommend doing this because the first time you change or reset your cPanel password, then your databases will stop working.


How to connect to the MySQL server remotely

Please see our related article on How to Connect to MySQL Remotely.


IMPORTANT UPDATE ! Since the 11.25 update, we've noticed a bug where you add an IP to the MySQL remote access list, only to find that the corresponding MySQL user that is created does not have any privileges.

In order to get the correct privileges added, you must go back to your MySQL Databases section in cPanel and re-add the user to each database (reassign the privileges). No need to remove the user first; just select the user and the database from the drop-downs and click "Add".

We've notified cPanel about the issue.



cPanelcPanel is a popular web hosting control panel that helps you manage your hosting account and assists you in creating web sites, managing e-mail addresses, & installing applications to a server.

cPanel is available on all HostGator Linux hosting plans, including Shared Hosting, Reseller Hosting, VPS and Linux Dedicated Servers.

Article Comments

Suzanne Mundy
Hi,

I am currently hosting two websites utilising Wordpress. They are both currently displaying the message "Error Establishing a Database Connection". This message appears and then a few minutes later the website can be viewed again. How can I fix this please? None of the files have been changed in any way although I did upgrade one of the sites to a newer version of Wordpress earlier today.

Thanks for your assistance,
Suzanne

HostGator
Check the wp-config.php file and make sure you are using a unique database username and password (in lieu of using your control panel username and password).

Next, call HostGator on the phone or join us in the live chat room. We will be glad to assist.

Brian Guiler
I am wanting to install a ebook store on mysql, but I dont know one thing about sql. someone please help

HostGator
You should not need to know anything about SQL.

Simply install the store per the installation instructions. Follow this article when it is time to enter the database (SQL) connection settings.

If the settings do not work, please contact us for help.

Joyce
I'm trying to connect via Dreamweaver and it's not working. The path is mt domain/var...

HostGator
To connect via Dreamweaver, you must follow the "How to connect to the MySQL server remotely" instructions.

Also, Dreamweaver usually requires the path/directory setting to be:

/public_html/

Joyce
I did that but there is no place for: MySQL Connection Port = 3306
TCP or UDP, either is fine. In the Connections panel

HostGator
You do not need to input those settings unless Dreamweaver asks.

Be sure to setup your home IP as an "access host" and then you should be able to connect.

Bill
I am trying to connect via MySQL Administrator and MySQL Query Browser but keep gettig a response which seems to be a password issue. I am using root and the root password. Am I amble to connect this way?

HostGator
Try the cPanel username and password.

Also, you may use the unique username and password assigned to your database. To understand that, read the "How do I create a MySQL database?" related article.

sandeep
i am hosting a joomla site at another company and would like to host my mysql database on host gator account.. is it possible.. do u provide remote access of data from a different server...

HostGator
Yes, that is clearly allowed. Please read the section of this article titled "How to connect to the MySQL server remotely".

Simply add your other host's IP address to your HostGator cPanel's Access Hosts.

christo
I'm experiencing access problems with a MySQL db user on HostGator. I'm using Joomla with added tables in the database.

I created the database from a dump off another server, and modified the php-config in Joomla to use my database instead of the default created.
The dbuser works perfectly for all Joomla tables, but when I want to select from the additional tables using my own php code, I get a "SELECT command denied to user" error.

Why is this ? How do I overcome it ?

HostGator
Check the users permissions by going to cPanel > MySQL Databases and clicking the username in the table next to the database name. This allows you to redefine the privileges. Make sure SELECT is checked.

Additionally, you may need to setup your PC as an Access Host.

Akshay Rajput
What hostname should i mention in wp-config.php?

HostGator
localhost

William Kirby
I have created a db user for my new database, but am unable to connect using the new username and password. I can only use my cpanel username and password. Also noticed I am unable to update privliedges on a user too?

HostGator
Be sure to use the entire new name. It will look like username_name and you must use the entire thing, including your cPanel username and the underscore.

You should be able to alter the user's permissions by clicking the user's name in the "Current Databases" table. However, this will only be possible if you have already submitted "Add User To Database" first.

If you still have problems, please contact our live support for help.

Greg
Hi,

Recently it seems there was a change in HostGator MySql settings. I can still remotely connect to MySql servers fine, but none of my databases appear after I connect. If I enter cPanel and grant "all privileges" on that database to the username I logged in as, and refresh in the MySql client, then the database appears. But the next day, it will be gone again, and I'll have to repeat the process. This only started happening recently. Are database permissions being reset every night? My apps and scripts still have no problem connecting.

HostGator
We have no similar reports from other users.

I suggest using your cPanel username and password, instead of the database username and password.

Your cPanel user has all privileges for all databases associated with that cPanel.

Adam
Is it possible to remote in to MySQL using Terminal on Mac OS X v10.6.2?

HostGator
Yes, provided that you have the MySQL client installed on your Mac. Access via port 3306.

John
I need some help setting up a remote mysql connection through dreamweaver,so i type in all the infor required and hit test. i keep getting a error that theres no test server running and that one of the problems might be the URL Prefix.

ive tried everything from my ip adress to my domain name but its does not seem to work. any help?


HostGator
Use either the IP address or domain name and prefix it with http://

EXAMPLE
http://mydomain.com
http://12.34.56.78

If this does not work, please contact HostGator via phone or live chat.

cfreyre
Hi, i have the same problem of GREg, it seems there was a change in HostGator MySql settings. I can still remotely connect to MySql servers fine, but NONE OF MY databases appear after I connect, only information_schema... i use my cpanel user access and it is the same.

what it is the trouble?

HostGator
First, be sure you have created a database via the MySQL Databases icon in cPanel.

Second, be sure to set your personal IP address as an Access Host.

If it still doesn't work, contact HostGator via phone or live chat.

HostGator
Greg,

We finally were able to reproduce the error you are getting.

I added the details at the end of this article.

ours
I am trying to set up the remote connection through MS Access. Could you please tell me what exactly I have to do to do so?

I use Office 2007.

Thanks.

HostGator
MS Access only works with a Windows dedicated server (ordered from http://www.hostgator.com/windows-dedicated-servers.shtml ).

If you have this type of hosting plan, then please contact HostGator via phone or live chat for help.

cahit
I want to establish a database connection, but I get the following error message.

Access denied for user '........'@'localhost' (using password: NO)

HostGator
This means you did not update the configuration file, correctly. In fact, you haven't even attempted to supply a password to the file.

Now is the time to contact us via email, phone or live chat for database configuration assistance. We will show you how to properly code this.

BWhite
Ok, I'm trying to connect to mysql with Dreamweaver, and I keep getting an Access Denied message.

I sent an email asking may IP to be whitelisted for 3306, and you guys responded back and said that it had been done (thanks for being so quick about it!). I also added my IP to the hosts in the Remote MySQL section - I even added it again, but used % for the last two number groups of the IP to make sure it would work. And still, it doesn't work.

Here are my Dreamweaver settings:

Testing Server (and this part connects fine)-
FTP Host : ftp.mysite.com
Host Directory : public_html/

MySQL Connection-
MySQL Server: http://[insert_server_ip_address_here] (I assume that this is the IP found under account information in the CP - right?)
Username: cp-login-name_database-username (Also tried the CP username)
Password: The password for the database user (Also tried the CP password along with the CP username)


I then click "Select Database", and it tells me-
"An FTP error occured - cannot open remote folder public_html/.
Access denied. The file may not exist, or there could be a permission problem."

So, naturally, the next thing I tried was to get rid of "public_html" and just leave the testing server's host directory box empty. Well, here's the error I got after that:
"HTTP Error Code 404 File Not Found. Here are some possible reasons for the problem:

1) There is no testing server running on the server machine.
2) The testing server specified for the site does not map to the http://ftp.[my_site_name].com/_mmServerScripts/MMHTTPDB.php URL.
Verify that the URL Prefix maps to the root of the site."

So, that didn't work either. Any ideas?

Thanks!

B White

HostGator
Please contact us via email, phone or live chat for assistance.

yorch s
Hi, For remote connection. I did re-add the user to the database after add the host ip addres but can't connect. Get the message:

Access denied for user 'beyondth_akrprot'@'f5.b6.354a.static.theplanet.com' (using password: YES)

Thanks.
Yorch

HostGator
You should be using the remote server's IP address.

If you still have problems, contact us via email, phone or live chat for assistance.

Cabir Pekdemir
Please Help;
Go all the way here, I try, but it does not happen. I want something simple. I want the remote server address in full,
http://74.53.x.xxx
or
http://xxxxxxx.com

HostGator
It doesn't work that way. MySQL databases do NOT have web URLs. You need SSH, cPanel, or a PHP script to display the data.

I recommend you login to cPanel and click the phpMyAdmin icon. This will allow you to browse the tables and data.

Ravi
Excellent article, worked for me.

I used the following configuration in MySQL Administrator.

Server Host: XXX.XXX.XXX.XXX
Username: mywebsite_username
Password: XXXX

It doesn't work in first time, because I haven't read whole article. After reading further, I add my IP address in Remote MySQL and it works perfectly.

Thank you

Jason
How to solve if the error msg is "I cannot connect to the database because: mysqlnd cannot connect to MySQL 4.1+ using old authentication", i am trying to access remotely and i have set up the accesshost as "%" already

andy

HostGator
Please contact us via email, phone or live chat for assistance.

Jameel
Hi Guys!
I am using dreamweaver cs5 I had uploaded my database from local wamp server phpmyadmin to cpanel and database is showing in the cp. When I try to connect that database an error occured that shows access denied I also ask that guys who host my web to allow my Ip to for remote connection and he did it now I am getting same problem I am not sure what type of testing server I need to setup I currently setup FTP and it shows dreamweaver sucessfully connect to xxxsite.com but when try to connect my database using mysql connection I got that error Can you guys help what type of setting I need to connect I mean user name and password and mysql server name what else. Thank you In advance

HostGator
Please contact support@hostgator.com for assistance.

Thomas
Is there any way to create databases via the command line? I've logged into mysql with my root username and I'm still getting an "access denied" error. Do I have to use cpanel to do it?

HostGator
Yes, you must use the cPanel > MySQL Databases tool to create new databases.

You cannot create databases via shell, phpMyAdmin, MySQL, nor any custom script (like a PHP page).

farhang
hi
thanks
this tut was very useful.

Reinaldo
There is also a problem in Dreamweaver 8.0.2, if the password for the database has a ( + ) in it.

HostGator
Thank you for your comments. Just a quick reminder that the comments on this page are not monitored by technical support staff, and that for support issues, it is best to contact us by live chat, phone or email so we can assist you right away.

Although comments are not monitored by technical support staff, they are moderated and read by technical writers. Comments will need to be approved by a moderator before appearing.

Our technical writers do read the comments periodically for the purposes of updating the articles, and do appreciate your feedback, suggestions and corrections to the articles themselves, as well as any suggestions or tips for readers of this article. However, support questions posted here are not guaranteed to be replied to in a timely manner or at all. For support issues, it is best to contact our support staff instead by live chat, email or phone.



Your comments help us keep the knowledge base updated. This is not a medium for support. If you have questions or need help, please contact us via email, phone or live chat for fast assistance.

Post Comment