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.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_', '/../../');

PrestaShop 1.7

  1. Using your FTP client or file manager open this file: /app/config/parameters.php
  2. Find the lines with database_host, database_name, database_userand database_password 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
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',
  ),
);

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

  1. 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

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

Leave a Reply

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