To connect to a MySQL database on your account, you will require the following five pieces of info:
- Hostname
- Database name
- Database username
- Database password
- Connection settings
If connecting from a script on the server, the hostname is “localhost”.
If connecting remotely, the hostname is your domain name.
If you encounter difficulties when using “localhost”, try using the IP address 127.0.0.1.
The database name and database username must be entered exactly as they appear in the MySQL Databases section of your control panel (cPanel).
Remember that when you name a database or create a username, your cPanel username will always be added to the beginning. For example, if your cPanel username is “zebra123” and you create a database called “savanna”, your database name will actually be: zebra123_savanna.
Note that there is an 8-character limit on database usernames. If you enter a username longer than eight characters, those extra characters will be automatically dropped.
Although it is possible to have more than one username assigned to a database, HostPapa strongly recommends against doing this.
The database password refers to the password you specified when creating the database username. Forget your user password? You may be able to find it in the script’s config file or you can remove the username from the database and then create a new password by adding the username back again. Note, though, that you may need to edit the script’s config file if you use the latter method.
Make sure you have added the database user to the database by selecting the user and the database from the drop-down lists and then clicking on the Add User to DB button. You should see connection code provided if you have done this.
For more information, we offer video tutorials about MySQL.
If you need help with your HostPapa account, please open a support ticket from your dashboard.