Setting up a database connection in CodeIgniter


With host localhost the connection will not work. The host address must be taken from the data to connect to the database.

Database connection data in CodeIgniter, the database settings are specified in the configuration file:

  • In case of using a file .env you need to change the lines by first deleting the hash symbol at the beginning of the lines #:
    database.default.hostname = database host.default.database = база_database data.default.username = login database.default.password = password database.default.DBDriver = MySQLi
    database.default.DBPrefix =
    database.default.port = 3306
  • In case of using a file app/Config/Database.php you need to change the lines:
    public $default = [
            'hostname' => 'host',
            'username' => 'login',
            'password' => 'password',
            'database' => 'база_data',
            'DBDriver' => 'MySQLi',
            'DBPrefix' => '',
            'port'     => 3306,

You can select the required PHP version by instructions.

You can make changes to files using filemanager or any FTPclient.