Setting up connection with the database in Opencart

In Opencart, 2 files are responsible for connection to the database:

  • config.php - which is located in the root
  • admin/config.php - which is located in the admin folder

The code for connecting to the database in both files is identical.

define('DB_HOSTNAME', 'servername');

define('DB_USERNAME', 'username');

define('DB_PASSWORD', 'password');

define('DB_DATABASE', 'database_name');