在终端输入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. Java实习生面试题整理

    一.数据类型 包装类型 八个基本类型: boolean/1 byte/8 char/16 short/16 int/32 float/32 long/64 double/64 基本类型都有对应的包装类 ...

  2. Winform窗体控件自适应大小

    自己写的winform窗体自适应大小代码,代码比较独立,很适合贴来贴去不会对原有程序造成影响,可以直接继承此类或者把代码复制到自己的代码里面直接使用 借鉴了网上的一些资料,最后采用重写WndProc方 ...

  3. VCard介绍

    91助手和豌豆荚用VCard来存储通讯录,今天调查了一下. 1. 方案 使用VCard存储通讯录,文件扩展名为 vcf,  数据文件可以直接导入IPhone/Windows Phone/android ...

  4. 多页Excel转换成PDF时如何保存为单独文件

    通过ABBYY PDF Transformer+图文识别软件,使用PDF-XChange打印机将多页Excel工作簿转换成PDF文档(相关文章请参考ABBYY PDF Transformer+从MS ...

  5. 如果BarTender出现卸载不干净的问题如何处理

    自从BarTender 2016出了之后,好多小伙伴都想试试新功能咋样,这就意味着首先要卸载电脑上旧版BarTender.然而就是这个操作,难倒了好一批人,他们表示BarTender卸载卸不干净,不仅 ...

  6. linux环境中,ssh登录报错,Permission denied, please try again.

    问题描述: 今天早上一个同事反应一个问题,通过ssh登录一台测试机的时候,发现两个账号,都是普通账号,一个账号能够登录, 另外一个账号无法登录.问他之前有做过什么变更吗,提到的就是之前有升级过open ...

  7. Git------如何使用Git Bash Here提交代码

    转载:码云帮助文档地址 http://git.mydoc.io/?t=154712 1.打开“Git Bash Here” 2.输入: ssh-keygen -t rsa -C "xxxxx ...

  8. 8 -- 深入使用Spring -- 4...3 AOP的基本概念

    8.4.3 AOP的基本概念 AOP从程序运行角度考虑程序的流程,提取业务处理过程的切面.AOP面向的是程序运行中各个步骤,希望以更更好的方式来组合业务处理的各个步骤. AOP框架并不与特定的代码耦合 ...

  9. PHP如何获取本周周二的日期?

    在计算某个特定周几的时候,需要对当前时间做一个转换和比对,比如,如何求出本周周二的时间日期. 代码如下: <?php // 如何计算本周的星期二 $time=time();//时间 $now=d ...

  10. iOS开发--UILineBreakModeWordWrap deprecated

    在iOS6中UILineBreakModelWordWrap deprecated 现在推荐使用 [label setLineBreakMode:NSLineBreakByWordWrapping];