Access denied for user 'root'@'pop-os' when running migrations on external host

Viewed 34

I'm trying to run laravel migration on another mariadb in the same network (for localhost it works fine). I'm able to access this database using mysql -u root -p 192.168.2.100 just fine.

However using php artisan migrate I get an error Error message:

SQLSTATE[HY000] [1045] Access denied for user 'root'@'pop-os' (using password: YES) (SQL: select * from information_schema.tables where table_schema = 92.168.2.166 and table_name = migrations and table_type = 'BASE TABLE')

I am running this from pop-os (linux) , but I do not understand why it's using this as a host? I do not have 'pop-os' in my configuration anywhere.

Configuration ENV File:

DB_CONNECTION=mysql
DB_HOST=192.168.2.100
DB_PORT=3306
DB_DATABASE=Laravel_db
DB_USERNAME=root
DB_PASSWORD=***

database.php (mysql)

'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'Laravel_db'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', 'password'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

laravel version 9.29.0

1 Answers

Are you sure there is an database user named 'root' with password you are using?

Try to log directly into that database (for example from console) and see if that works.

Also try to give permissions to user 'root':

GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip_address' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
Related