0

I have this error when i try to access to my laravel home project that have db access.

I know this is a common issue, so I have already read many post and tried this:

  • check if username and password was correct (The same user and password work from command line and from MySql Workbench );
  • check permission on Sql Side. There is an entry for root@localhost
  • clean cache .env and restart server many times. I also tried to insert temporarily the db info directly on database.php

database.php

 'default' => 'mysql',
 'mysql' => [
        'driver' => 'mysql',
        'dump_command_path' => '/opt/lampp/bin', // only the path, so without 'mysqldump' or 'pg_dump'
        'dump_command_timeout' => 60 * 5, // 5 minute timeout
        'dump_using_single_transaction' => true, // perform dump using a single transaction
        'host' => env('DB_HOST', '10.8.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', ''),
        'username' => env('DB_USERNAME', ''),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
    ],

.env

#MYSQL
DB_HOST=127.0.0.1 //I have tried also localhost
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
jack_0
  • 61
  • 6
  • try putting DB_PASSWORD="" – Vedran Mile Tomljanovic Sep 06 '18 at 22:00
  • you cannot connect to root from a remote host unless this is specified in MySQL config. Therefore create a new MySQL user, give him rights to connect from all hosts `*` create password and it should work... Side note: if using VMs like homestead for example by localhost you are referring to this VMs local database and not your actual host or `DB_HOST` defined in `.env`, so you need to keep that in mind... – Bart Sep 07 '18 at 00:16
  • Silly question, but do you actually have a password in `.env`? Error msg says `using password: NO`, which makes me wonder. – Don't Panic Sep 07 '18 at 06:23
  • @VedranMileTomljanovic It is not working – jack_0 Sep 07 '18 at 10:05
  • @Bart The db is locate on my mac. I have no VM and i gava permission to access to root@localhost – jack_0 Sep 07 '18 at 10:05
  • @Don'tPanic I have no password in MySql Server, so I have not in my .env file – jack_0 Sep 07 '18 at 10:07
  • Are there more details in a log? – Vedran Mile Tomljanovic Sep 08 '18 at 09:23
  • 1
    @jack_0 MySQL is some kind of tricky here. Using root user and with no password or NULL, seems like a really bad practice, even in the development For the sake of mind you need to have a valid user with password and proper access to the database from your ip. So please create one new user, with proper permissions and post your errors, if any arise... – Bart Sep 10 '18 at 01:46
  • @VedranMileTomljanovic here the full log https://imgur.com/a/vbS6v8Q – jack_0 Sep 11 '18 at 08:17
  • @Bart This is the default configuration on MySql tomorrow I will try to modify it and I will let you know. Thank you for your help. – jack_0 Sep 11 '18 at 08:18
  • @Bart I changed password as you sad and It's working now. Thank you so much for your help – jack_0 Sep 12 '18 at 17:01

0 Answers0