Reputation: 428
I am on a problem since yesterday that I can not solve.
The error appears when I want to connect to the database of a host, the error is No such file or directory
, I looked for the path of the socket file and the path is / var / run / mysqld /mysqld.sock
so I changed the file path. Locally its function the solution that I have on the net but in production no
here is the conf of the laravel .env
file
DB_Connection = mysql
DB_HOST = hXXmysqlXXX
DB_PORT = 3306
DB_DATABASE = XXX_test
DB_USERNAME = XXX_bdd
DB_PASSWORD = XXXX
'# DB_SOCKET = / tmp / mysql.sock (it's a comment)
DB_SOCKET = /var/run/mysqld/mysqld.sock
Unfortunately, this did not solve the error.
Could you help me solve the problem?
Thank you
(I have already researched the problem and did not find a solution.Excuse me for my english, it's not my mother tongue)
Upvotes: 2
Views: 9314
Reputation: 1795
Are you looking for connect to a local database or a remote database (a database located on other computer/server) ?
On Unix, MySQL programs treat the host name localhost specially, in a way that is likely different from what you expect compared to other network-based programs.
For connections to localhost, MySQL programs attempt to connect to the local server by using a Unix socket file. This occurs even if a --port or -P option is given to specify a port number.
To ensure that the client makes a TCP/IP connection to the local server, use --host or -h to specify a host name value of 127.0.0.1, or the IP address or name of the local server. You can also specify the connection protocol explicitly, even for localhost, by using the --protocol=TCP option.
protocol could be {TCP|SOCKET|PIPE|MEMORY}
in short: you don't have to specify a sock file for remote connections.
Upvotes: 3