PrestaShop makes use of a MySQL database to store product information and other settings for your online store. When installing or moving PrestaShop, there are database credentials that are needed in order for PrestaShop to establish a link to the database. Depending on whether you are performing a new install of PrestaShop, or moving an existing PrestaShop store to a new server, the steps to resolve a database connection error can vary. In this article, we will go through each scenario and guide you through resolving the Link to Database Cannot be Established eror in PrestaShop.
If you see Link to database cannot be established when installing PrestaShop, this indicates an incorrect database setting. To resolve, review the following PrestaShop database settings and correct as needed:
Hostname: | localhost |
---|---|
Database name: | Make sure this is the full database name which will be prefixed with your cPanel user name(e.g. userna5_mydatabase) |
Database username: | Check to be sure you are using the database user assigned to the database, and not just the cPanel username (e.g. userna5_dbuser). |
Password: | This should be the password for the database user assigned to the database. You can change the database user's password, if needed. |
When performing a new installation of PrestaShop, the first part of the process is to create a MySQL database and database user. Our tutorial on creating a MySQL database walks you through step-by-step, how to create the database and database user with the MySQL Database Wizard in cPanel. If you created your database without using the wizard, but didn't create a user and assign the user to your database, please see our tutorial on how to create and assign a user to a database.
Once you make any needed corrections to the database settings, you can continue with your new PrestaShop installation.
If you are seeing Link to Database Cannot be Established on a PrestaShop site that you moved to a new server, this indicates an error in the PrestaShop configuration file. When moving an existing installation of PrestaShop to a new server, there are several steps involved beyond just moving your site's files.
Once you have moved your PrestaShop site files, the next step is to create a MySQL database on the new server. Next, import your PrestaShop database into the new database. Finally, your PrestaShop configuration file will need to be updated with your new database credentials. The PrestaShop configuration file is named settings.inc.php and can be found inside the config folder of your PrestaShop directory.
You can easily update the PrestaShop configuration file using the cPanel File Manager. Once you have the file open for editing, the lines you will want to check and adjust as needed are the database name, database server, database user, and database password. Examples are as follows
define('_DB_NAME_', 'whhsup5_presta'); | Replace the the DB_NAME value (enclosed with single quotes) with your new database name. On Web Hosting Hub servers the database name is prefixed with your cPanel user name. |
---|---|
define('_DB_SERVER_', 'localhost'); | On Web Hosting Hub servers, you will want to make sure that the DB_SERVER value (enclosed with single quotes) is set to localhost |
define('_DB_USER_', 'whhsup5_presta'); | Replace the the DB_USER value (enclosed with single quotes) with your new database user. On Web Hosting Hub servers the database user is prefixed with your cPanel user name. |
define('_DB_PASSWD_', 'yourpassword'); | Replace the the DB_PASSWD value (enclosed with single quotes) with your new database password. |
Once you have updated your PrestaShop configuration file with the correct database settings, refresh your website your browser and your PrestaShop site should appear.
Email: | support@WebHostingHub.com | Ticket: | Submit a Support Ticket |
---|---|---|---|
Call: | 757-416-6627 | Chat: | Click To Chat Now |
We value your feedback!
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
new! - Enter your name and email address above and we will post your feedback in the comments on this page!