HostGator.com » Support Portal

How to connect to the MySQL database

Configuration Settings:
Host = localhost (really, put localhost)
Database name = (cpanelusername_databasename)
Database username = (cpanelusername_databaseusername)
Database password = (******)

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

Configuration Settings:
Host = (use the server IP address)
Database name = (cpanelusername_databasename)
Database username = (cpanelusername_databaseuser)
Database password = (******)
MySQL Connection Port = 3306
TCP or UDP, either is fine.

Before you can connect to MySQL from another computer, you must enable your computer as an access host. It may sound confusing, but cPanel makes this very simple.

Before reading, try watching the movie tutorial.

  1. Login to cPanel and click the Remote MySQL icon, under Databases.
  2. Type in the connecting IP address, and click the Add Host button.
  3. All done, try connecting remotely.

How can I find out my computers IP address?
Simple, just go to hostgator.com/ip.shtml

Wait a minute, my IP constantly changes.
Okay, you have a dynamic IP address. Therefore, every time you go online, or every once in awhile, your IP changes. You have a few options here. The most secure, would be to update your IP in Remote MySQL every time your IP changes. However, you do have other options available. You could simply enter % (a percentage sign) in the Add Access Hosts text field. This will allow any IP to remotely connect to your databases. Another option: Lets say the first two parts of your IP never change. Then, you could enter 93.138.%.% , where the first two parts are your actual IP address numbers.



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.


If you have read our knowledge base and still have questions or need more information, please contact us via phone or live chat for immediate assistance.

Post Comment