我正在尝试使用Laravel中的Homestead连接到数据库。我收到错误
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using
password: NO)
当我用git bash迁移php artisan时,以及刷新主页时也在浏览器中。我尝试更改.env并清除缓存,但未成功。任何帮助表示赞赏。这是我的代码。
.env
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=33060
DB_DATABASE=real-estate-laravel
DB_USERNAME=homestead
DB_PASSWORD=secret
主机
192.168.10.10 real-estate-laravel.test
127.0.0.1 phpmyadmin.test
答案 0 :(得分:0)
遵循这些步骤
$ mysqld --skip-grant-tables
然后,执行这些语句。
$ mysql -u root mysql
$mysql> UPDATE user SET Password=PASSWORD('your_password') WHERE USER='root';
$mysql> FLUSH PRIVILEGES;
如果您在使用时遇到未知字段“密码错误”,请尝试以下操作:
update user set authentication_string=password('your_password') WHERE user='root';
最后,在没有--skip-grant-tables
选项的情况下重新启动守护程序。
$ /etc/init.d/mysql restart
现在,您可以使用新密码进行连接了。
$ mysql -u root -p
输入密码
your_password