在终端输入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. python 使用循环生成list

    #-*- coding:UTF-8 -*- squares=[] for x in range(10): squares.append(x**2) print squares #[0, 1, 4, 9 ...

  2. CorelDRAW中六种复制对象的方法详解

    复制可保证对象的大小一致,复制也是所有操作中最基本的操作.CorelDRAW软件中支持多种复制对象的操作,本教程将详解CorelDRAW中六种复制对象的方法. 方法一 选择复制对象,点击编辑→复制,再 ...

  3. centos6.8 安装Python2.7后, yum出现“No module named yum”错误

    出现yum错误:No module named yum 解决方法,查看 /usr/bin下python有哪几个版本 ll /usr/bin 我这里是:2.6  和  2.7 (刚安装的) 由于yum命 ...

  4. javascript生成m位随机数

    根据时间生成m位随机数,最大13位随机数,并且不能保证首位不为0 function ran(m) { m = m > 13 ? 13 : m; var num = new Date().getT ...

  5. 让Json更懂中文(JSON_UNESCAPED_UNICODE)

    我们知道, 用PHP的json_encode来处理中文的时候, 中文都会被编码, 变成不可读的, 类似”\u***”的格式, 还会在一定程度上增加传输的数据量. <?php echo json_ ...

  6. C# base和this的用法

    /** this关键字* this关键字引用类的当前实例* 注意:静态成员方法中不能使用this关键字,this关键字只能在实例构造函数.实例方法或实例访问器中使用*/ /** base关键字* ba ...

  7. JVM虚拟机内存模型以及GC机制

    JAVA堆的描述如下: 内存由 Perm 和 Heap 组成. 其中 Heap = {Old + NEW = { Eden , from, to } } JVM内存模型中分两大块,一块是 NEW Ge ...

  8. python BeautifulSoup库用法总结

    1. Beautiful Soup 简介 简单来说,Beautiful Soup是python的一个库,最主要的功能是从网页抓取数据.官方解释如下: Beautiful Soup提供一些简单的.pyt ...

  9. 采用Post方式提交数据实例

    项目目录 一.编写MainActivity.java package com.hyzhou.getdemo; import com.hyzhou.getdemo.service.LoginServer ...

  10. Nginx(十二)-- Nginx+keepalived实现高可用

    1.前提 两台Linux服务器,IP分别为192.168.80.128 和 192.168.80.129,都安装Nginx和keepalived,并启动. 2.配置双机热备 1.将192.168.80 ...