在终端输入mysql,结果出现

macdeMacBook-Pro:~ mac$ alias mysql=/usr/local/mysql/bin/mysql
macdeMacBook-Pro:~ mac$ mysql
ERROR (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

在网上搜到很多方法,不好使,然后查询了官方文档

http://dev.mysql.com/doc/refman/5.7/en/can-not-connect-to-server.html

下面写道

Here are some reasons the Can't connect to local MySQL server error might occur:

  • mysqld is not running on the local host. Check your operating system's process list to ensure the mysqld process is present.

  • 。。。

没想到第一条就符合,然后我尝试输入mysqld

结果:

macdeMacBook-Pro:bin mac$ mysqld
--10T07::.997151Z [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
--10T07::.997492Z [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
--10T07::.997557Z [Note] mysqld (mysqld 5.7.) starting as process ...
--10T07::.003105Z [Warning] Setting lower_case_table_names= because file system for /usr/local/var/mysql/ is case insensitive
--10T07::.004893Z [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
--10T07::.004919Z [Note] InnoDB: Uses event mutexes
--10T07::.004926Z [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
--10T07::.004932Z [Note] InnoDB: Compressed tables use zlib 1.2.
--10T07::.005337Z [Note] InnoDB: Number of pools:
--10T07::.005498Z [Note] InnoDB: Using CPU crc32 instructions
--10T07::.007117Z [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = , chunk size = 128M
--10T07::.018796Z [Note] InnoDB: Completed initialization of buffer pool
--10T07::.035212Z [Note] InnoDB: Highest supported file format is Barracuda.
--10T07::.051578Z [Note] InnoDB: Creating shared tablespace for temporary tables
--10T07::.051764Z [Note] InnoDB: Setting file './ibtmp1' size to MB. Physically writing the file full; Please wait ...
--10T07::.065007Z [Note] InnoDB: File './ibtmp1' size is now MB.
--10T07::.065856Z [Note] InnoDB: redo rollback segment(s) found. redo rollback segment(s) are active.
--10T07::.065868Z [Note] InnoDB: non-redo rollback segment(s) are active.
--10T07::.066135Z [Note] InnoDB: Waiting for purge to start
--10T07::.121419Z [Note] InnoDB: 5.7. started; log sequence number
--10T07::.121762Z [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
--10T07::.122048Z [Note] Plugin 'FEDERATED' is disabled.
--10T07::.133391Z [Note] InnoDB: Buffer pool(s) load completed at ::
--10T07::.134352Z [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
--10T07::.134366Z [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
--10T07::.135842Z [Warning] CA certificate ca.pem is self signed.
--10T07::.135903Z [Note] Skipping generation of RSA key pair as key files are present in data directory.
--10T07::.142139Z [Note] Server hostname (bind-address): '127.0.0.1'; port:
--10T07::.142191Z [Note] - '127.0.0.1' resolves to '127.0.0.1';
--10T07::.142330Z [Note] Server socket created on IP: '127.0.0.1'.
--10T07::.195770Z [Note] Event Scheduler: Loaded events
--10T07::.195949Z [Note] mysqld: ready for connections.
Version: '5.7.22' socket: '/tmp/mysql.sock' port: Homebrew

等一大串错误之类的 ,最后退出了

最后,正确的方法:

macdeMacBook-Pro:~ mac$ sudo mysqld_safe
Password:
Logging to '/usr/local/var/mysql/macdeMacBook-Pro.local.err'.
--10T07::.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
--10T07::.6NZ mysqld_safe mysqld from pid file /usr/local/var/mysql/macdeMacBook-Pro.local.pid ended
macdeMacBook-Pro:~ mac$ mysql
ERROR (): Access denied for user 'mac'@'localhost' (using password: NO)

然后mysqld服务就运行啦

此时,终于能够打开mysql

Mac - Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)的更多相关文章

  1. Mac mySql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)的解决办法

    我的环境:Mac 10.11.6 ,mysql  5.7.14  . mac mySql 报错ERROR 2002 (HY000): Can't connect to local MySQL serv ...

  2. mac ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    好久不用mysql,今天突然想用的时候, mysql -uroot -p 直接报了下面的错误 ERROR 2002 (HY000): Can't connect to local MySQL serv ...

  3. Mac下安装Mysql出现 Can’t connect to local MySQL server through socket '/tmp/mysql.sock'

    在Mac下安装mysql出现 Can't connect to local MySQL server through socket '/tmp/mysql.sock' 错误,解决如下: $ unset ...

  4. Mac下Mysql启动异常["ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"]

    在mac下使用brew安装mysql,之前没有使用过,今天启动的时候发现启动不了 huijundeMacBook-Pro:bin huijunzhang$ mysql ERROR (HY000): C ...

  5. mac使用brew安装mysql报RROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    使用mac安装mysql安装完后运行 mysql -uroot -p 报了 ERROR 2002 (HY000): Can't connect to local MySQL server throug ...

  6. mac 安装mysql 报错“ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2)” 解决办法

    首先安装 homebrew 再 brew install mysql 之后连接 mysql 无论是登录还是修改初始密码都会报如下的错误 ERROR 2002 (HY000): Can not conn ...

  7. Mac端解决(含修改8.0.13版的密码):Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    1. 安装mysql但是从来没启动过,今天一启动就报错: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 ...

  8. 长久不用的mysql报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    mac上安装过mysql: 然而,尝试连接时报错: $ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to lo ...

  9. XtraBackup出现 Can't connect to local MySQL server through socket '/tmp/mysql.sock'

    Xtrabackup做备份时遇到下面错误信息MySQL server: Can't connect to local MySQL server through socket '/tmp/mysql.s ...

随机推荐

  1. ubuntu 12.04 右上角的网络连接图标突然消失不见

    某天Ubuntu右上角的网络连接图标突然消失不见了,右击panel -> add to panel -> Notification Area 也不管用,最关键的是上不了网了.可以在Netw ...

  2. 修改linux终端DIR显示颜色

    头疼死,linux终端下,目录颜色蓝色在黑色的背景下,睁大双眼都看不清楚. 找办法修改,找到默认的颜色设置目录: # vi /etc/DIR_COLORS 查看文件,并查找DIR: 可以看到默认设定“ ...

  3. QT 随机数生成

    下面总结了QT中随机生成的方法(仅供学习参考),分为旧方法和新方法,一般来说,旧的方法已经被抛弃,在开发新的应用中推荐使用新方法.  C++ Code  12345678910111213141516 ...

  4. 【转】ZooKeeper详细介绍和使用第一节

    一.分布式协调技术 在给大家介绍ZooKeeper之前先来给大家介绍一种技术——分布式协调技术.那么什么是分布式协调技术?那么我来告诉大家,其实分布式协调技术 主要用来解决分布式环境当中多个进程之间的 ...

  5. go反射的规则

    第一次知道反射的时候还是许多年前在学校里玩 C# 的时候.那时总是弄不清楚这个复杂的玩意能有什么实际用途……然后发现 Java 有这个,后来发现 PHP 也有了,再后来 Objective-C.Pyt ...

  6. IIS------如何安装IIS

    1.打开“控制面板”->“程序”->“打开或关闭Windows功能” 2.如图所示: 3.如图所示: 4.点击确定,配置完成

  7. webApi之FromUri和FromBody区别

    public Link GetLink([FromUri] FileRequest fileRequest) { if (ModelState.IsValid) { var xml = WebConf ...

  8. iOS开发-修改UITableViewCell中image和title的位置和大小

    最近在开发中遇到需要Cell中imageView和textLable位置和大小的情况,设计希望得到的结果如下图所示: 而TableViewCell默认样式,image是靠紧左边的,并且image和ti ...

  9. Nginx(十)-- 进程模型及工作原理

    1.nginx进程模型 Nginx是一个master和worker的模型.master主要用来管理worker进程,master就比作老板,worker就是打工仔,master指挥worker来做事情 ...

  10. MQTT-C-PUB

    /* ============================================================================ Name        : mqtest ...