PDO DSN 的官方文档页面尚未列出用户名或密码。这些键值对的正确名称是什么?
最佳答案
看起来文档还没有更新,但是this is the related change来自 PHP 的源存储库,说明了应该如何使用它:
PDO: The username and password can now be specified as part of the PDO DSN for the mysql, mssql, sybase, dblib, firebird and oci drivers. Previously this was only supported by the pgsql driver. If a username/password is specified both in the constructor and the DSN, the constructor takes precedence.
new PDO("mysql:host=xxx;port=xxx;dbname=xxx;user=xxx;password=xxx");
关于php - 如何在 DSN 中指定用户名和密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59448952/