MySQL: connection problem of socket
I work on MAC OS. I try to connect to the database (mysql) to save data
Code:
mysqli_connect('localhost','root','','base_gives')
but I get the error below:
Quote:
Warning: mysqli_connect() [FUNCTION.mysqli-connect]: (HY000/2002): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)
When I connect to the local IP address, I can not find the web page saying that the apache server works
Anyone any idea?
Re: MySQL: connection problem of socket
If you are with MAMP, by default it is apache and mysql on non standard ports (8888 and 8889 type).
So either you tell him to connect on standard ports (80 and 3036, is a specific button), or you clear the port XXXX at the connection.
Re: MySQL: connection problem of socket
I uninstalled MAMP and now I do a pure terminal. Maybe uninstall MAMP changed something at that level
It seems to be a problem of location of the socket but I have yet defined in php.ini
Code:
mysql.default_socket = /tmp/mysql.sock
Re: MySQL: connection problem of socket
MAMP terminal is not in mac.
If you do a php-i you will normally it does not use any php.ini. So we need to specify the address that you have modified (-c I think, do -- help for all this). Or touching the environment variables but I know nothing on Mac.
And if you do I imagine that the terminal you started the MySQL server, we agree?
Re: MySQL: connection problem of socket
I think I just found the solution
I put this config in the 'php.ini'
Code:
mysqli.default_socket =/tmp/mysql.sock
address of the socket! And it works after apache restart!