António Santos wrote:
> Amazingly, no matter what port number I use, it always connect!
Then it isn't using TCP/IP, which is the only way to get it to use a
port number. You can verify this with netstat. While the program is
connected and running:
$ netstat -na |grep 3306
You should see nothing ESTABLISHED while it's connected with an invalid
port argument. (Assuming you have complete control of the machine so
you can ensure all other database users are stopped while testing.)
I did some experimenting and found that the C API uses Unix domain
sockets (mysql.sock) if you use 'localhost'. If you use 127.0.0.1, it
uses TCP/IP, here at least. You could also use the machine's "real" IP
address to be sure, at the possible cost of some inefficiency, depending
on how the kernel routes the calls. If it has to bounce through the
Ethernet driver, it's better to use 127.0.0.1 if you can.
> I installed mysql++ using yum.
Try MySQL++ v3.0. I just said this here:
$ ./exrun resetdb -uroot -pupward1 -s127.0.0.1:3307
and got "Connection failed: Can't connect to MySQL server on '127.0.0.1'
(111)" This is on a CentOS 5.1 system running the official MySQL 5.0.45
binaries. If I leave the :3307 off, change it to 3306, or use
'localhost', it does connect.