在Linux上使用C连接到lampp mysql数据库
我从 XAMPP 网站下载并安装了最新的 XAMPP for linux "开发包" .
现在我想用C连接MySQL数据库,上面的包中似乎没有包含mysql.h
。
我按照 此 链接中给出的说明进行操作。我安装了 libmysqlclient15-dev 但在运行测试程序(上面第二个链接中给出的示例)时给出了错误消息。
无法通过套接字“/var/run/mysqld/mysqld.sock”连接到本地 MySQL 服务器(2)
上述位置没有 mysqld.sock
文件。但是/opt/lampp/var/mysql
中有一个mysql.sock
文件(这是安装LAMPP的地方)。
我应该怎么做才能连接LAMPP自带的MySQL服务器? 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试创建一个指向文件实际位置的符号链接,并告诉我们它是否有效。如果这是问题所在,您当然可以覆盖该文件的默认路径设置。
如何创建符号链接:这可以通过在终端中执行以下命令来完成。需要root用户权限:ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock
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
您可以从浏览器连接到
xampp
吗?如果不能,请执行以下操作:现在您有一个打开的默认套接字。
Can you connect to
xampp
from the browser? If you can't, do the following:Now you have an open default socket.