database 如何在 Laravel 5 中配置 MariaDB?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31650972/
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 configure MariaDB in Laravel 5?
提问by Parthapratim Neog
I have read somewhere that, there is no driver for "MariaDB" in Laravel 5 and that we can use mysql driver to use MariaDB in Laravel 5. But even then I am getting this error when i give my MariaDB username and password. The password is "root" and username is also "root".
我在某处读到过,Laravel 5 中没有“MariaDB”的驱动程序,我们可以使用 mysql 驱动程序在 Laravel 5 中使用 MariaDB。但即便如此,当我提供我的 MariaDB 用户名和密码时,我还是收到了这个错误。密码是“root”,用户名也是“root”。
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
Can someone guide me on how to configure MariaDB to be used with Laravel 5.
有人可以指导我如何配置 MariaDB 以与 Laravel 5 一起使用吗?
回答by Parthapratim Neog
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3307'),
'database' => env('DB_DATABASE', 'doctorsondemand'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'root'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
Well, the problem was with the port. By default it is not mentioned and they take it as 3306. So, we have to include that line and mention that the port is 3307. That solved the problem. Hope this helps.
好吧,问题出在端口上。默认情况下没有提到它,他们将其视为 3306。因此,我们必须包含该行并提及端口是 3307。这解决了问题。希望这可以帮助。