I'm developing an application in c++ in OSX Yosemite that uses mysql. I've installed both mysql and mysql-connector-c++ using brew.

I could use the library without any problems until recently, butnow I'm having some problems.

Basically, when I try to run my application I get the following error:

libc++abi.dylib: terminating with uncaught exception of type 
sql::SQLException: Unknown MySQL server host 'K@??' (0)

I've checked and I'm correctly passing the host name, which is localhost. I've tried to reinstall mysql-connector-c++ but the problem remains. Does anyone have any idea on how to fix this?

I'm using mysql version 5.7.14 and mysql-connector-c++ version 1.1.6_1.

closed as off-topic by nohillside Sep 12 '16 at 4:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development are off-topic here, but can be asked on Stack Overflow." – nohillside
If this question can be reworded to fit the rules in the help center, please edit the question.

  • What does it show in the debugger and also what exception does it throw and try catching it – user151019 Sep 2 '16 at 18:45
  • @Mark I'm not using a debugger, but the exception when caught says only: Unknown MySQL server host '2???' (0). Notice that each time I try, the supposed host name in the exception changes – BrunoB Sep 2 '16 at 18:52
  • Well if you are developing you should - especially in these cases. No-one will bother answering if you have not done the basics – user151019 Sep 2 '16 at 18:54
  • I've tried compiling from the source and installing the connector, tried the connection using the SqlString provided by the library and I also tried an earlier version. None of that solved. – BrunoB Sep 2 '16 at 18:54
  • Stop trying random acts - either follow the source and work out what is going wrong, have enough test cases to see what is wrong for use a debugger. – user151019 Sep 2 '16 at 18:55

I also got this problem. I guess the reason is the mismatch between macos and mysqlconn. The latest mysqlconn binary release only supports up to macos 10.10 and the latest macos is 10.11. I compiled the driver myself and the issue has gone. So you can try to compile that yourself and it should work. Here are the commands I used:

cmake -DMYSQL_CONFIG_EXECUTABLE=/usr/local/Cellar/mysql/5.7.15/bin/mysql_config -DCMAKE_INSTALL_PREFIX=~/
make;make install

Then you can just include ~/include and ~/lib for your header and libs. Hope this works for you. If this still does not work, try to check whether you used the same gcc for both mysqlconn and your program. brew now installs gcc 6.2 but mac only carries 4.2.

  • thank you for your comment. I have already tried to compile myself but I didn't think about the difference on the compilers. I'll try to do what you said and get back to you. – BrunoB Sep 12 '16 at 21:27
  • It works!! The problem was really the compiler. I uninstalled the connector in brew, downloaded the source again, compiled and installed it. I then read the cmake output and noticed that it was using a different compiler, so I used the same when compiling my code and it seems fine now. Thanks! – BrunoB Sep 13 '16 at 17:31
  • Because the question is off-topic here I'm not sure if they'll keep it. If you want I can put on stackoverflow, you answer there and I marked as solve. Then I delete this one here. – BrunoB Sep 13 '16 at 17:33
  • No problem. I am happy my solution works for you. – wangfengfight Sep 14 '16 at 19:59

Not the answer you're looking for? Browse other questions tagged .