“Can't connect … through socket '/tmp/mysql.sock' ” using C API mysql_real_connect()
Posted by:
Jeff Brown
Date: January 07, 2021 07:19PM
Hi All
I'm running OS 11.1 Big Sur and updating an objective C program that uses the MySql C API (NOT the C Connector). I CAN connect to local MySql server from the command line using
/usr/local/mysql/bin/mysql --user=root --password=aPassword
but when my software tries to connect through the C API using mysql_real_connect(mSQLPtr, theHost, theLogin, thePass, theDatabase, 0, NULL, 0); it fails with:
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (1)
I've read heaps of posts to try and fix it e.g. stopping and starting the server, checking that /tmp/mysql.sock file does exist after starting the server (AND IT DOES EXIST), and adding a my.cnf to the /etc folder. It contains:
[mysqld]
socket=/tmp/mysql.sock
[client]
socket=/tmp/mysql.sock
I've also done chmod 777 /tmp/mysql.sock
Nothing has worked so far. Can anyone offer any suggestions please.
Cheers Jeff
Subject
Views
Written By
Posted
“Can't connect … through socket '/tmp/mysql.sock' ” using C API mysql_real_connect()
993
January 07, 2021 07:19PM
454
January 15, 2021 12:34PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.