简体   繁体   English

cpanel 中的 mysql 数据库拒绝 laravel 连接

[英]laravel connection refused with mysql database in cpanel

I have deployed new laravel 8 application in cpanel.I'm having trouble connecting to the mysql database to laravel application deployed in capnel.我已经在 cpanel 中部署了新的 Laravel 8 应用程序。我无法将 mysql 数据库连接到部署在 capnel 中的 Laravel 应用程序。 In my local environment database connection works fine .在我的本地环境数据库连接工作正常。 However on my remote server it does not work.但是在我的远程服务器上它不起作用。

my .env looks like this我的 .env 看起来像这样

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=project_db
DB_USERNAME=root
DB_PASSWORD=dev

when DB_HOST=127.0.0.1 it shows当 DB_HOST=127.0.0.1 它显示

error sqlstate[2002] connection refused(select * from)错误 sqlstate[2002] 连接被拒绝(选择 * 来自)

when DB_HOST=localhost it shows当 DB_HOST=localhost 它显示

error sqlstate[2002] no such file or directory(select * from)错误 sqlstate[2002] 没有这样的文件或目录(选择 * 来自)

can you guys spot my error Thanks in advance你们能发现我的错误吗 提前谢谢

You simply have to set the appropriate credidentials to match the Server credidentials.您只需设置适当的凭证以匹配服务器凭证。

ex前任

DB_CONNECTION=mysql
DB_HOST=(Server Ip)
DB_PORT=(Server port)
DB_DATABASE=(The database name set on the server)
DB_USERNAME=(The username that was set on the database set up)
DB_PASSWORD=(The password that was set on the database set up)

Also check for any file name syntax errors.还要检查任何文件名语法错误。 Cause the error being generated error sqlstate[2002] no such file or directory(select * from) says that it cannot find the file with the name (select * from).导致正在生成error sqlstate[2002] no such file or directory(select * from)说它找不到名称为 (select * from) 的文件。

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

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