Connection settings for MySQL databases Print

  • Updated on 07-May-2024
  • 26

To connect to a MySQL database, you typically need the following connection settings:

1.        Hostname

2.        Database name

3.        Database username

4.        Database password

5.        Port Number

If connecting from a script on the server, the hostname is localhost”.

If connecting remotely, the hostname is your domain name.

Database name: cpuser_db,Database username: cpuser_dbuser,Database password

Port Number: 3306

For PHP:

$dbh=mysql_connect ("localhost", "cpuser_dbuser", "password") or die ('I cannot connect to the database because: ' . mysql_error());

mysql_select_db ("cpuser_db");

Note: For example, if your cPanel username is “Asia787” and you create a database called “Pakistan”, your database name will be Asia787_Pakistan.


Was this answer helpful?

« Back