开发者

Connecting to lampp mysql database using C on Linux

开发者 https://www.devze.com 2023-02-21 18:04 出处:网络
I downloaded and installed XAMPP for linux latest \"Development package\" from XAMPP website. Now I want to connect to MySQL database with C and it seems mysql.h is not included in above package.

I downloaded and installed XAMPP for linux latest "Development package" from XAMPP website.

Now I want to connect to MySQL database with C and it seems mysql.h is not included in above package.

I followed instructions given in this link. I installed libmysqlclient15-dev but an error message is given when a test program (example 开发者_如何转开发given in above second link) is run.

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

There is no mysqld.sock file in above location. But there is a mysql.sock file in /opt/lampp/var/mysql (this is where LAMPP is installed).

What should I do in order to connect with MySQL server that comes with LAMPP? Thank you


Try creating a symlink to where the file actually is, and tell us if it worked. If that's the problem, surely you can override the default path setting for that file.

How to create the symlink: This can be done by executing the following command in the terminal. Root user permissions are required: ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock


Can you connect to xampp from the browser? If you can't, do the following:

sudo /etc/init.d/apache2 stop

sudo /opt/lampp/lampp start

Now you have an open default socket.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号