迁移时用户 root@localhost 的 Laravel 5.4 访问被拒绝 [英] Laravel 5.4 access denied for user root@localhost on migrate

查看:26
本文介绍了迁移时用户 root@localhost 的 Laravel 5.4 访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Laravel 有一个 stange .我有一个坏习惯,就是用 laravel 项目在虚拟盒子上创建项目进行测试.(debian last stable 目前是 9.1, nginx, php7.1, MariaDB).

I have a stange one with Laravel. I have a bad habit of creating projects on virtual box with laravel project for testing. (debian last stable currently 9.1, nginx, php7.1, MariaDB).

在你告诉我去某个地方阅读另一篇文章之前,请阅读所有内容,我可能错过了这篇文章,但我尝试了很多我尝试了大多数可能对其他人有用的解决方案,但它们在我的案例(谢谢).

Before you tell me to go read another post somewhere, please read everything, I mays have missed the post but I tried quite à lot I tried most of the solution that may have worked for others, but they don't in my case (thanks).

我尝试了不同的东西并且总是结束一切并做悬停(这很正常......).

I tried different thing and always end breaking everything and doing hover (that's normal...).

我已经尝试了很多安装,从来没有遇到任何问题

I have already tried a number of installation and never had any problem with

php artisan migrate

直到今天.我准备了我的迁移文件并尝试了迁移,我收到了这条消息:

That is until today. I prepared my migrations files and tried the migrate and I got this message :

[IlluminateDatabaseQueryException]
  SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: sele
  ct * from information_schema.tables where table_schema = test and table_nam
  e = migrations)

还有这个:

[PDOException]
  SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'

我一如既往地做了所有事情,我检查了 .env 文件中的凭据并对其进行了测试.没问题.

I did everything as always, I checked my credentials that are in the .env file and tested them. No problem there.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=Password2

数据库确实存在,这个名字不能错:

The database does exist, can't be wrong with this name :

SHOW DATABASEs;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+

在 MariaDB 中查找代码错误 1698 时,他们告诉我在尝试无密码连接时出现此代码.

When looking for code error 1698 in MariaDB, they tell me that this code appear when it's trying to connect without password.

所以我的问题是它为什么要这样做?我尝试了一个新项目,刚刚安装并执行 artisan 命令行,它没有任何改变.

So my question is why is it doing this? I tried with a new project, just installed and doing the artisan command line, it changes nothing.

我想避免重新安装操作系统.

I would like to avoid doing a fresh os install.

提前感谢您的帮助,并为我糟糕的英语感到抱歉.

Thanks in advance for your help and sorry for my poor english.

推荐答案

所以我的问题解决了...好像需要新建一个数据库账号才能写入数据库,不能使用root...

So I solved my problem... It seems that I need to create a new database account to write in the database and can't use root...

我用另一台虚拟机对其进行了测试,如果我创建一个新帐户,它应该可以正常工作...

I tested it with another virtual machine and if I create a new account it works as it should...

似乎问题出在 MariaDB 上...即使在 mysql_secure_installation 命令之后,我也可以使用或不使用密码连接到 root...我会处理这个...

Seems that the issue is with MariaDB... I can connect with or without password to root even after mysql_secure_installation command... I will work on this...

非常感谢.

这篇关于迁移时用户 root@localhost 的 Laravel 5.4 访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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