duanjuan3931 2012-12-13 09:54
浏览 198

Mac OSX 10.8 MySQL连接错误:localhost不起作用,127.0.0.1都可以

I have now a new MabBook with 10.8 and I am trying to set up all the Apache&MySQL etc. Apache successfully runs including vhosts.

in my /etc/hosts I have all the local hosts set including 127.0.0.1 localhost etc.

when I try to coennct to one of my local vhost, e.g. alpensonne, I can connect to MySQL without any troubles. if I try to have the MySQL host to be localhost, I get the follwoing error:

Database connection error (2): Could not connect to MySQL.

I know the error(2) means username or password incorrect, but they are fine. If I connect with

mysql -u root
SELECT password,host FROM user where user='root';

also I have just done to be double sure:

SET PASSWORD FOR 'root'@'localhost' = '';

Is it possible that localhost uses a different mysql socket? maybe it then tries to connect to a different mysql?

I hope someone can help me.

  • 写回答

3条回答 默认 最新

  • dtp19819 2012-12-13 10:57
    关注

    Ok I found the mistake... The problam was, that I have forgot to change the php.ini file to point to the mysql.default_socket... My default_socket was set to /var/mysql/mysql.sock so I just created a symlink to /tmp/mysql.sock and now all works fine! :)

    @shadyyx Thanks for the proposal of MAMP, I know this of course but not such a big fan of MAMP, XAMPP, LAMP etc. for windows user its good so you can use apache instead of IIS, but for Linux, Unix and also Mac user you can use the build in apache server... so no need to use an other third party software. also you are depended then on the php version etc. I like it more to be able to configure it myself.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c