M
M
max_mara2012-01-17 04:07:20
PHP
max_mara, 2012-01-17 04:07:20

mysql_connect() always tries to connect to localhost

mysql_connect('some_host.loc', 'test', 'test);

Gives error Can't connect to local MySQL server through socket /var/lib/mysql/mysql.sock

sql.safe_mode is off

Why is it trying to connect through mysql.sock

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
edogs, 2012-01-17
@edogs

Isn't socket=/var/lib/mysql/mysql.sock spelled out in my.cnf?

E
egorinsk, 2012-01-17
@egorinsk

Look through strace/netstat (if you're on Windows, then through procmon/procexp) where PHP actually connects and what happens before, for example, if it tries to resolve the server name.

I
Ilya Plotnikov, 2012-01-17
@ilyaplot

It's time to punish the use of mysql_ functions. If possible, use PDO.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question