0

I'm using Laravel 5.2 and phpMyAdmin (which I'm running through InstantWordpress) and when I try to migrate the database I get this error message from the command line:

[PDOException]
SQLSTATE[HY000] [2002] no connection could be made because the target machine actively refused it

This is what my .env file looks like:

APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:IBh/yuGAXTC2a2rRD7A9VE5io7AbPXLYfJUfLyFnRfA=
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=micedb
DB_USERNAME=roo
DB_PASSWORD=roo

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

Then, when I look at the app in the browser I have a landing page as though the initial migrate has worked but there's nothing in the database and when I try to register I get an error message and stack trace.

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
tdrsam
  • 527
  • 1
  • 8
  • 28
  • Probably you mean MySQL (or MariaDB) instead of phpMyAdmin. phpMyAdmin is an application used by administrators to manage their database servers; it's not a database itself. – Isaac Bennetch Apr 23 '16 at 23:38
  • I'm fairly sure I've been using phpMyAdmin. It comes as part of InstantWordPress (which is pretty good). I think I'm going to try MySql or another type of DB as I just don't seem to be able to connect to the DB I made. I've always been able to before but Laravel doesn't seem to want to connect. I'll try another method when I get some time. – tdrsam Apr 25 '16 at 00:39

1 Answers1

2

In Config->database

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', 'localhost'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'DBName'),
    'username' => env('DB_USERNAME', 'root'),
    'password' => env('DB_PASSWORD', ''),
    'charset' => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix' => '',
    'strict' => false,
    'engine' => null,
],

In .env file :

DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=DBName
DB_USERNAME=root
DB_PASSWORD=

Close the laravel application server and restart again for clearing the cache.

 php artisan serve

Try this. Good luck!

Sunil
  • 1,106
  • 1
  • 7
  • 17
  • I tried this exactly as it is. I tried replacing `DBName` with the name of the database in the env file, then I tried using the name of the database in both files. I get the same error message every time. I have my DB software stored on the secondary drive on my computer, but I have the laravel app on the same drive. That wouldn't have anything to do with it, would it? – tdrsam Apr 22 '16 at 06:31
  • i think no problem with that because am also using like that only. – Sunil Apr 22 '16 at 06:34
  • what is the colour of WAMP icon? – Sunil Apr 22 '16 at 06:37
  • Not WAMP. InstantWordpress. – tdrsam Apr 22 '16 at 06:39
  • I strongly believe that the connection with the server is not properly established because of the port number. Try DB_port=''. I am using Wamp and have less knowledge about Instant WordPress. – Sunil Apr 22 '16 at 06:47
  • I used two single quotes but still got the same error message. I suspect it could be the port as well. InstantWordpress is an Apache/2.2.15 web server. It doesn't specify a port number but the url in the browser that phpMyAdmin runs in is this: `http://127.0.0.1:4001/phpmyadmin/index.php?db=micedb&token=e0adfafec98dc1aaf27edd316830beaa` – tdrsam Apr 22 '16 at 07:04
  • Try changing the database.php like : ( 'DB_HOST', '127.0.0.1' ); and ('DB_PORT', '4001') – Sunil Apr 22 '16 at 07:09
  • Still no good, but I looked in phpMyAdmin and found this sql error `Unknown column 'Event_priv' in 'field list'` Also, no users with privileges to the the db – tdrsam Apr 22 '16 at 07:22
  • Check this for granting the privilege : http://stackoverflow.com/questions/5016505/mysql-grant-all-privileges-on-database – Sunil Apr 22 '16 at 07:39
  • No good. Wonder if it's to do with my php.ini file. I'm using the production version of the file rather than the development version. In my phpMyAdmin I have five different users, one of which is 'production' for which the user is root and the host is production. – tdrsam Apr 22 '16 at 10:00