doudu9652
2017-06-20 06:51
浏览 68
已采纳

使用XAMPP 1.6.2附带的PHP独立MySQL安装

I have installed XAMPP 1.6.2 (need this use this specific version) at /opt/lampp in Ubuntu 16.0.4. I have installed Mysql 5.7.18-0ubuntu0.16.04.1 using apt-get. I need to use the installed version of MySQL with PHP that came with XAMPP.

When I try to connect PHP with MySQL (independent installation), I get this error:

Can't connect to local MySQL server through socket '/opt/lampp/var/mysql/mysql.sock'

I am still getting this error after trying the following things:

  1. Replaced all occurrences of '/opt/lampp/var/mysql/mysql.sock' with '/var/run/mysqld/mysqld.sock' in /opt/lampp directory.
  2. Restarted Apache, MySQL.
  3. Rebooted system.
  4. Searched on Stackoverflow, and tried existing solutions (eg. edit my.cnf)

Please help me out; Thanks.

图片转代码服务由CSDN问答提供 功能建议

我在Ubuntu 16.0的/ opt / lampp安装了XAMPP 1.6.2(需要使用此特定版本)。 4. 我已经使用apt-get安装了Mysql 5.7.18-0ubuntu0.16.04.1。 我需要使用随XAMPP附带的PHP安装的MySQL版本。

当我尝试连接PHP与MySQL(独立安装)时,我收到此错误:

无法连接到 本地MySQL服务器通过socket '/opt/lampp/var/mysql/mysql.sock'

nn

我在尝试以下事情后仍然收到此错误:

  1. 在/ opt中将所有'/opt/lampp/var/mysql/mysql.sock'替换为'/var/run/mysqld/mysqld.sock' / lampp目录。
  2. 重启Apache,MySQL。
  3. 重新启动系统。
  4. 在Stackoverflow上搜索,并尝试了现有的解决方案(例如。 编辑my.cnf)

    请帮帮我; 谢谢。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongshi6528 2017-08-22 09:40
    已采纳

    I solved this issue simply by replacing localhost with 127.0.0.1 in my.cnf file.
    As Fmashiro pointed out, this could have happened due to missing / corrupted socket file.

    已采纳该答案
    评论
    解决 无用
    打赏 举报