0

I'm following the Hands-On project for course Laravel Essentails on Tutsplus. I created an app on PagodaBox and cloned it into my local system. After that, I install Laravel-4-Generator from https://github.com/JeffreyWay/Laravel-4-Generators and generated resources for my project: model, view, controller, database seed, etc. Next, I try to run

php artisan migrate:install snippets

But I got the following error:

[PDOException]                                                                               
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)  

I don't know what's homestead user here. Here is my database file for this project

'default' => 'mysql',
'connections' => array(

    'sqlite' => array(
        'driver'   => 'sqlite',
        'database' => __DIR__.'/../database/production.sqlite',
        'prefix'   => '',
    ),

    'mysql' => array(
        'driver'    => 'mysql',
        'host'      => isset($_SERVER['DB1_HOST']) ? $_SERVER['DB1_HOST'] : 'localhost',
        'database'  => isset($_SERVER['DB1_NAME']) ? $_SERVER['DB1_NAME'] : 'snippets',
        'username'  => isset($_SERVER['DB1_USER']) ? $_SERVER['DB1_USER'] : 'root',
        'password'  => isset($_SERVER['DB1_PASS']) ? $_SERVER['DB1_PASS'] : '',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
    ),

And here is the result when I check grants for 'homestead'@'localhost':

mysql> SHOW GRANTS FOR 'homestead'@'localhost';
+---------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for homestead@localhost                                                                                                              |
+---------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'homestead'@'localhost' IDENTIFIED BY PASSWORD '*A4B6157319038724E3560894F7F932C8.......F' WITH GRANT OPTION |
+---------------------------------------------------------------------------------------------------------------------------------------------+

P/S: I have created the snippets database in mysql and I'm an Ubuntu 14.04 machine. Has anyone experienced this before. What should I do as I don't understand what the error is here.

DucCuong
  • 638
  • 1
  • 7
  • 26
  • `$_SERVER['DB1_USER']` is your database username – Jordan Doyle Jun 07 '14 at 12:59
  • No. I used Laravel 4 quickstart from pagodabox.com and this setting was automatically generated by pagodabox. I just change the database to 'snippets'. Btw, I tried to remove those $_SERVER[..] things. But the problem still remains. @JordanDoyle – DucCuong Jun 07 '14 at 13:05
  • do you have a user 'homestead' at your local mysql? – fortune Jun 07 '14 at 13:07
  • No, I don't. Actually, I tried to create homestead in mysql, and grant all privileges to that account but it didn't resolve my problem! – DucCuong Jun 07 '14 at 13:08
  • http://stackoverflow.com/questions/23733626/php-mysql-connectivity-error/23734447#23734447 check this – fortune Jun 07 '14 at 13:11
  • @fortune I created the 'homestead' user but it did not resolve my problem at all. – DucCuong Jun 07 '14 at 13:19
  • have u updated the database connection in you php script accordingly? – fortune Jun 07 '14 at 13:29
  • @fortune Yes. The configuration now is: 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'snippets', 'username' => 'homestead', 'password' => '1234', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), I can log in to mysql with this homestead account on command line – DucCuong Jun 07 '14 at 13:30
  • @DucCuong have u apply mysql> FLUSH PRIVILEGES; at mysql cmd – fortune Jun 07 '14 at 13:41
  • Yes, I did but it didn't help. I've tried to recreate that user on mysql, grant privileges, flush privileges three times and the problem keeps occuring – DucCuong Jun 07 '14 at 13:48
  • @DucCuong have you checked in php.ini file that extension=pdo_mysql.so is enabled? – fortune Jun 07 '14 at 14:02
  • you can do it with phpinfo(); it shows that pdo for mysql is enabled or not – fortune Jun 07 '14 at 14:06
  • @fortune Yes, it's enabled... – DucCuong Jun 07 '14 at 14:15

1 Answers1

0

View Users created:

mysql> select user,host from mysql.user;
+------+----------------------+
| user | host                 |
+------+----------------------+
| root | %                    |
| root | 127.0.0.1            |
| root | ::1                  |
| root | imac.de.yadira.local |
|      | localhost            |
| root | localhost            |
|      | mor-mac.local     |
+------+----------------------+
7 rows in set (0.00 sec)

copy imac.de.yadira.local and replace hostname in my case it was mor-mac.local

$env = $app->detectEnvironment(array(

    'local' => array('imac.de.yadira.local'),

));

and now runs:

mor-mac:resposive yadira$ php artisan migrate:install
Migration table created successfully.
Arctodus
  • 5,743
  • 3
  • 32
  • 44
yaya
  • 1