简体   繁体   中英

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. In my local environment database connection works fine . However on my remote server it does not work.

my .env looks like this

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

error sqlstate[2002] connection refused(select * from)

when DB_HOST=localhost it shows

error sqlstate[2002] no such file or directory(select * from)

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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