What Are My Database Credentials?

Your database credentials will comprise of a hostname, your database name and your database user, which is prefixed with your account name. In this article, we'll provide an example what a database config should include and where you can get this information from. * * * ## Your Database Hostname Your database hostname credential will always be 'localhost'. Therefore in the connection config, this should include: ``` /** MySQL hostname */ define('DB_HOST', 'localhost'); ``` * * * ## Your Database Name and Database User If you know that you have a database on your account but you are unsure what the database name is or what database user has access, you can review this via the control panel. Log into your cPanel account. If you are unsure on how to do this, please view the following help article - '[How to log into cPanel](https://hostpresto.com/help/article/1)'. ![alt text](https://i.imgur.com/QRmld56.png "Datbase details 1") Scroll down to the '**Databases**' section and choose '**MySQL Databases**'. ![alt text](https://i.imgur.com/ypijhjZ.png "Datbase details 2") At the top under the '**Current Databases**', you should find your database listed. Note that this includes the database name under the '**Database**' heading and the database user under the '**Privileged Users**' heading. ![alt text](https://i.imgur.com/imdkFMg.png "Datbase details 3") We therefore now know that our database credentials consist of our account name (hpdemouk in this example) followed by an underscore and the database name (new in this example). Coincidentally, our database user is the same. Therefore our database config will now also include: ``` /** The name of the database */ define('DB_NAME', 'hpdemouk_new'); /** MySQL database username */ define('DB_USER', 'hpdemouk_new'); ``` * * * ## Your Database Password A database does not have a password, only the database user that has access does. If you know your password, add the following line to your database config replacing the password example with your actual password. ``` /** MySQL database password */ define('DB_PASSWORD', 'PASSWORDEXAMPLE'); ``` If you are not sure what this password is, you can change the database user password. Still in '**MySQL Databases**', scroll further down to the '**Current Users**' section. Select the '**Change Password**' option on the database user as noted from earlier. ![alt text](https://i.imgur.com/m2YM3DN.png "Datbase details 4") * * * Type in your new password for the database user in the '**Password**' box and repeat again in the '**Password (Again)**' box. Note that there's a 'Password Generator' option if you would like the system to generate you a strong new password. ![alt text](https://i.imgur.com/wBtsa4v.png "Datbase details 5") * * * Once your new password has been entered, complete the process by choosing the '**Change Password**' option. ![alt text](https://i.imgur.com/fBWmSc8.png "Datbase details 6") Now update the database config with the new password that you've set by adding this line: ``` /** MySQL database password */ define('DB_PASSWORD', 'NEWPASSWORDEXAMPLE'); ``` * * * ## Full Database Credentials Your database config should consist of: ``` /** MySQL hostname */ define('DB_HOST', 'localhost'); /** The name of the database */ define('DB_NAME', 'youraccount_yourdatabasename'); /** MySQL database username */ define('DB_USER', 'youraccount_yourdatabaseuser'); /** MySQL database password */ define('DB_PASSWORD', 'PASSWORDEXAMPLE'); ```
  • 0 کاربر این را مفید یافتند
آیا این پاسخ به شما کمک کرد؟

مقالات مربوطه

How to log into cPanel

There are two different methods to log into your cPanel control panel in order to manage every...

What's the difference between Aliases, Addon and Subdomains?

### Aliases An Alias domain does not have a unique website. It is a domain that is masked to...

Creating a MySql Database

If your website uses PHP or you need to hold a collection of records which need to be accessed...

Importing a MySql Database

You can import a MySQL database via phpMyAdmin which is available in the cPanel control panel....

Exporting a MySql Database

You can export a MySQL database via phpMyAdmin, available in cPanel, if you want to keep a backup...