如何使用 MAMP 将 Laravel 应用程序连接到 MySQL?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18241721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to connect a Laravel app to MySQL using MAMP?
提问by Joshua Lee
SOLVED: I followed what this website said http://forums.laravel.io/viewtopic.php?id=980I just added 'unix_socket' to the mysql array and it worked!
已解决:我按照这个网站所说的http://forums.laravel.io/viewtopic.php?id=980我刚刚添加了 'unix_socket' 到 mysql 数组并且它工作了!
I am following the Laravel quick start guide at http://laravel.com/docs/quick
我正在关注http://laravel.com/docs/quick 上的 Laravel 快速入门指南
I have everything set up and am using MAMP. When I try and view the /public/users
page, I am hit with:
我已经设置好了一切,并且正在使用 MAMP。当我尝试查看/public/users
页面时,我遇到了:
PDOException
SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)" error.
PDO异常
SQLSTATE[28000] [1045] 用户 'root'@'localhost' 的访问被拒绝(使用密码:YES)”错误。
My database.php
file looks like so:
我的database.php
文件看起来像这样:
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'todolist',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
My MAMP displays:
我的 MAMP 显示:
host localhost
port 8889
user root
password root
My question is, is the MySQL on MAMP's separate from the MySQL tables I have created locally? I am assuming yes because I am not able to see the tables on PHPMyAdmin. If so, is there a way to connect my Laravel app to MAMP's MySQL?
我的问题是,MAMP 上的 MySQL 是否与我在本地创建的 MySQL 表分开?我假设是,因为我看不到 PHPMyAdmin 上的表格。如果是这样,有没有办法将我的 Laravel 应用程序连接到 MAMP 的 MySQL?
回答by Erin Drummond
MAMPs MySQL is running on port 8889, so add 'port' => '8889'
to your config array
MAMPs MySQL 在端口 8889 上运行,因此添加'port' => '8889'
到您的配置数组