zoukankan      html  css  js  c++  java
  • os x lion下mysql5安装后提示2002错误

    mysql5在mac os x下的安装,可以直接下载dmg安装包安装,也可通过prot安装,,过程比较容易。

    在安装完成后,却发现出错:运行 mysql5 -u root,提示:

    mysql5 -u root –p  

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)

    后来下了个mysql的管理工具:Mysql WorkBench,通过右下角的创建数据库实例,发现可以连接到数据库上。。如下图

    在参考了http://www.iteye.com/problems/49993 之后,在连接数据库时加上主机就可以访问ok啦:

    mysql5 -u root -h 127.0.0.1
    xxx$ mysql5 -u root -h 127.0.0.1
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 6
    Server version: 5.5.17 MySQL Community Server (GPL)

    Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    mysql> quit
    Bye

    在连接成功后:

    mysql> show variables like 'socket';  
    +---------------+-----------------+
    | Variable_name | Value |
    +---------------+-----------------+
    | socket | /tmp/mysql.sock |
    +---------------+-----------------+
    1 row in set (0.03 sec)

    发现sock的路径,于是做一个软连接即可:

    $ sudo ln /tmp/mysql.sock /opt/local/var/run/mysql5/mysqld.sock 

    随后在终端输入mysql5即可进入mysql控制台。

    参考:http://www.iteye.com/problems/49993

  • 相关阅读:
    关于C++值传递与引用传递的汇编层面分析
    scrapy抓取的中文结果乱码解决办法
    scrapy抓取的中文结果乱码解决办法
    CSS选择器
    CSS选择器
    xpath选择器
    操作系统知识
    鸟哥的私房菜:Bash shell(五)-数据流重导向
    鸟哥的私房菜:Bash shell(四)-Bash shell的使用环境
    鸟哥的私房菜:Bash shell(三)-命令别名与历史指令
  • 原文地址:https://www.cnblogs.com/rainduck/p/2235222.html
Copyright © 2011-2022 走看看