如何在Laravel 5中配置MariaDB? [英] How to configure MariaDB in Laravel 5?

查看:1452
本文介绍了如何在Laravel 5中配置MariaDB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某处读到,在Laravel 5没有驱动程序MariaDB,我们可以使用mysql驱动程序在Laravel 5中使用MariaDB。但即使这样,我得到这个错误,当我给我的MariaDB用户名和密码。密码为root,用户名也为root。

  SQLSTATE [HY000] [1045] root'@'localhost'(使用密码:YES)

有人可以指导我如何配置MariaDB要与Laravel 5一起使用。

解决方案

 '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',
'collat​​ion'=> 'utf8_unicode_ci',
'prefix'=> '',
'strict'=>好了,问题出在 port

强>。默认情况下,没有提到它们,它们把它作为3306.所以,我们必须包括该行,并提及端口是3307.解决了问题。
希望这有帮助。


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".

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.

解决方案

'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.

这篇关于如何在Laravel 5中配置MariaDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆