简体   繁体   English

PHP Symfony4 Doctrine 驱动程序/身份验证问题(Windows 10)

[英]PHP Symfony4 Doctrine driver/authentication issue (Windows 10)

I've installed PHP, mySQL and Apache as separate components and have a skeleton app built with Symfony/Composer/Twig .我已经将 PHP、mySQL 和 Apache 安装为单独的组件,并使用Symfony/Composer/Twig构建了一个框架应用程序。

I'm trying to create a database using php bin/console doctrine:database:create .我正在尝试使用php bin/console doctrine:database:create创建一个数据库。

The error I'm getting is我得到的错误是

Error thrown while running command "doctrine:database:create".运行命令“doctrine:database:create”时抛出错误。 Message: "An exception occurred in driver: could not find driver"消息:“驱动程序发生异常:找不到驱动程序”

In AbstractMySQLDriver.php line 106: An exception occurred in driver: could not find driver在 AbstractMySQLDriver.php 第 106 行:驱动程序中发生异常:找不到驱动程序

In PDOConnection.php line 31: could not find driver在 PDOConnection.php 第 31 行:找不到驱动程序

In PDOConnection.php line 27: could not find driver在 PDOConnection.php 第 27 行:找不到驱动程序

Here is what I have tried so far:这是我迄今为止尝试过的:

  • Enabling the extension=pdo_mysql in php.ini This produces a different set of errors related to authentication.php.ini启用extension=pdo_mysql这会产生一组不同的与身份验证相关的错误。 I don't understand the ramifications of enabling this extension so unsure if that's a good rabbit hole to be going down or not.我不明白启用这个扩展的后果,所以不确定这是否是一个好的兔子洞。

  • In my.ini (equivalent to my.cnf for many others) I have made default_authentication_plugin=mysql_native_password based on the suggestions here I used mySQL Workbench to confirm the directory containing my.ini is where mySQL is pathing (maybe not the correct term).my.ini (相当于许多其他人的 my.cnf)中,我根据此处的建议default_authentication_plugin=mysql_native_passworddefault_authentication_plugin=mysql_native_password我使用 mySQL Workbench 来确认包含 my.ini 的目录是 mySQL 路径的位置(可能不是正确的术语)。

Many with this issue had problems with unconventional mysql usernames or passwords but I am using DATABASE_URL=mysql://root:root@127.0.0.1:3306/appname许多遇到此问题的人都遇到了非常规 mysql 用户名或密码的问题,但我使用的是DATABASE_URL=mysql://root:root@127.0.0.1:3306/appname

Any tips are appreciated!任何提示表示赞赏!

I noticed that you marked the question tagged: windows.我注意到您将问题标记为:windows。 Based on that, we can have the project running in a virtual environment (VitualBox), if in the virtual environment it was Enabling the extension=pdo_mysql in php.ini , but the command php bin/console doctrine:database:create or php.exe bin/console doctrine:database:create run on the local machine and not the virtual one;基于此,我们可以让项目在虚拟环境(VitualBox)中运行,如果在虚拟环境中启用了php.ini 中extension=pdo_mysql ,但是命令php bin/console doctrine:database:create extension=pdo_mysql php bin/console doctrine:database:createphp.ini php.exe bin/console doctrine:database:create在本地机器上运行而不是在虚拟机器上运行; you will need to enable extension=pdo_mysql in php.ini in the local development environment ( C:\\php\\php.ini )您需要在本地开发环境 ( C:\\php\\php.ini ) 中的php.ini中启用extension=pdo_mysql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM