[英]Laravel can't connect to DB
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) SQLSTATE [28000] [1045]拒绝访问用户'root'@'localhost'(使用密码:NO)
My database.php
includes the following setup (default set to mysql): 我的database.php
包括以下设置(默认设置为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();
). 然而,当我进入终端窗口时,我能够使用mysql -h localhost -u root -p
登录然后只需按Enter键进入而没有密码,我认为这是等效的('bt'表当我运行show databases();
)时出现。 What am I missing here? 我在这里错过了什么?
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
It's also possible that pdo is not installed on your machine. 您的计算机上也可能未安装pdo。 You can check if it's installed from the phpinfo() page or a php script 您可以从phpinfo()页面或php脚本中检查它是否已安装
if ( extension_loaded('pdo') ) {
.......
}
On linux you can install it by 在linux上你可以安装它
sudo apt-get install php5-mysql
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.