How to set up a database? Settings


#1

I have a laravel web site and I need to connect to the mysql db on the hosting. My settings in the config are:

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'test'),
        'username' => env('DB_USERNAME', 'test'),
        'password' => env('DB_PASSWORD', 'test'),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],

When I create new db on the hosting I get database like this: id111111_test and the same user and password. As I see I have replace all test with id111111_test in my config. Do I need replace 127.0.0.1 with localhost? And how to config port and driver? Thanks.


#2

@teodor @supun @akhilkumar332


#3
'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', 'localhost'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'your_dbname'),
        'username' => env('DB_USERNAME', 'your_username'),
        'password' => env('DB_PASSWORD', 'your_password'),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],

Replace db name, username password with the details you get in cpanel -> manage database