问题
I'm following through the Quick Start Guide, and got to the section actually connecting to the DB to fetch the users table, and am getting the following error:
SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
My database.php
includes the following setup (default set to mysql):
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'bt',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
When I go to the terminal window, however, I'm able to log in using mysql -h localhost -u root -p
then just hit enter to go in without a password, which I thought would be equivalent (the 'bt' table shows up when I run show databases();
). What am I missing here?
回答1:
I think this is the solution :)
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'bt',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefi
回答2:
It's also possible that pdo is not installed on your machine. You can check if it's installed from the phpinfo() page or a php script
if ( extension_loaded('pdo') ) {
.......
}
On linux you can install it by
sudo apt-get install php5-mysql
来源:https://stackoverflow.com/questions/20334627/laravel-cant-connect-to-db