How to change database connection settings in PrestaShop

Most frequently you may need to change database settings after moving to new hosting.
Here is how you can do that:


Be careful with these settings. Incorrect config will break your site.

PrestaShop 1.7

  1. Using your FTP client or file manager navigate to your PrestaShop root and open this file: /app/config/parameters.php
  2. Find the lines with database_host, database_name, database_user and database_password parameters.
  3. Replace existing values of those params by the new ones.
  4. Save the file and upload it back to the server.
  5. All done! Open your site in the browser and check whether it works.

IMPORTANT: sometimes you might need to manually clear the site cache to apply the settings. Delete all content of folder “/var/cache/” under the site root. You can do it by using your hosting file manager or by FTP. “/var/cache/” contains folders “dev”, “prod” and similar. Be careful not to delete something else.

Here is an example config:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php return array (
  'parameters' =>
  array (
    'database_host' => '127.0.0.1',
    'database_port' => '',
    'database_name' => 'your_database_name',
    'database_user' => 'your_database_user',
    'database_password' => 'your_database_password',
    'database_prefix' => 'ps_',
    'database_engine' => 'InnoDB',
    'mailer_transport' => 'smtp',
    'mailer_host' => '127.0.0.1',
    'mailer_user' => NULL,
    'mailer_password' => NULL,
    'secret' => 'Vz6rVXVYNWYt7E6Fvfvdfvg34MCdc97h3IttReewVIxNOu7wHAoS',
    'ps_caching' => 'CacheMemcache',
    'ps_cache_enable' => false,
    'ps_creation_date' => '2017-05-22',
    'locale' => 'en-US',
    'cookie_key' => 'xduROM3yvjDSym43CvfdvFDVD47YG8zCrVruNFjjZ3NUb7Ut9',
    'cookie_iv' => '7kBvdfvgh',
    'new_cookie_key' => 'def00000766ffa61aae49b279evfsdvsdfvsfdvfdvwerr324r3frdfveb1afedc8702a964f0a1f6828bf1623ca54efad10ed4bbfb289beec62b01a3062d4c3ce78254157',
  ),
);

PrestaShop 1.5 – 1.6

  1. Using your FTP client or file manager open this file: /config/settings.inc.php
  2. Find the lines with _DB_SERVER_, _DB_NAME_, _DB_USER_ and _DB_PASSWD_ parameters.
  3. Replace existing values of that params with the new ones.
  4. Save the file and upload it back to the server.
  5. All done! Open your site in the browser and check whether it works.

Here is an example config:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
define('_DB_SERVER_', 'localhost');
define('_DB_NAME_', 'your_database_name');
define('_DB_USER_', 'your_database_user');
define('_DB_PASSWD_', 'your_database_password');
define('_DB_PREFIX_', 'ps_');
define('_MYSQL_ENGINE_', 'InnoDB');
define('_PS_CACHING_SYSTEM_', 'CacheApc');
define('_PS_CACHE_ENABLED_', '0');
define('_COOKIE_KEY_', 'VydXpBBvqfdVyGyVY44qVfFTvL23AG1szj0Avsd271PtuNw5CbORvvOIs');
define('_COOKIE_IV_', 'PIx53ASw');
define('_PS_CREATION_DATE_', '2017-05-07');
define('_PS_VERSION_', '1.6.1.14');
define('_RIJNDAEL_KEY_', '4H8PRpv43fsdDSuZXUx9iLiiwRb2af5');
define('_RIJNDAEL_IV_', '8Xav8t+xvdft54D+k/KI1g==');
define('_PS_DIRECTORY_', '/../../');

7 thoughts on “How to change database connection settings in PrestaShop”

  1. For 1.7, the “database_password” was encrypted. Once I changed it, how to encrypt it and update into the /app/config/parameters.php

  2. Hello Respected brothers ,
    Today I just initialized prestashop in my webhost,
    but i encountered this Error;

    1. SQL error on query Specified key was too long; max key length is 1000 bytes

    How may I rectify this problem I really need your assistance at the utmost urgency, Thank You

  3. Hi, I need help with Prestashop 1.7.4.3. I want to conct my database, but I did not find the parameters.php in this directoty: app/config.

  4. Ah, I forgot to edit these 3 tables:
    PRSTSHP_SHOP_DOMAIN
    PRSTSHP_SHOP_DOMAIN_SSL
    PRSTSHP_SHOP_URL

  5. Hi polosat,
    Thanks for the info for Prestashop 1.7 – but I have an issue. After cloning my site using Plesk from domain A to domain B and editing the DB connection file on domain B, connecting to domain B redirects me to domain A – I feel like more needs to be configured, any ideas where?

    1. test with this file you will find the informations of connection

      /app/cache/prod/appProdProjectContainer.php

Leave a Reply to Airil Shah Cancel reply

Your email address will not be published. Required fields are marked *