mysql - 有关laravel链接数据库的问题
PHPz
PHPz 2017-04-17 12:06:56
0
2
708

用laravel4.2写了个项目,在本地做测试的时候是没有问题的
然后现在把项目搬到阿里云上之后 使用

php artisan migrate

显示

SQLSTATE[28000] [1045] Access denied for user 'root'@'XXXXXXXX' (using password: YES)

用户名和密码是正确的 因为通过

mysql -uroot -p

可以登录
下面是我的代码

'mysql' => array(

        'driver'    => 'mysql',

        'host'      => 'XXX.XXX.XXX.XXX',

        'database'  => 'sing',

        'username'  => 'root',

        'password'  => 'XXXXX',

        'charset'   => 'utf8',

        'collation' => 'utf8_unicode_ci',

        'prefix'    => '',

    ),

所以想请问一下 出现这样的问题的话怎么解决

PHPz
PHPz

学习是最好的投资!

reply all(2)
迷茫

If you are accessing the database locally
Put
'host' => 'XXX.XXX.XXX.XXX',
Change to
'host' => 'localhost' or 'host' => '127.0.0.1'
If the database is called remotely.
Then you need to add remote calling permissions to the user. Please refer to Baidu

for specific operations.
黄舟

mysql -uroot -p
Add the -h parameter to this command (corresponding to the host configuration in laravel) to see if it can still be connected.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template