在终端输入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. Android学习之——ListView

    背景知识 ListView在Android应用中使用非常广泛,手机上必备的微博.网易新闻等,都使用了ListView.

  2. IT管理就这么管

    随着信息系统的广泛应用,员工没有电脑就无法工作,企业离开信息系统就无法顺利开展业务.信息部作为企业的内部信息化部门,承担了包括软件开发.系统维 护.硬件维护的几乎所有IT相关任务,对保障公司业务系统的 ...

  3. python之文件目录和路径

    1.路径中不要出现中文,否则有极大可能报错 2.反斜杠问题 举例说明: 我们从Windows复制的文件路径是G:\beifen\Tea. 可以看到,路径用的是反斜杠:\. 由于反斜杠\在python里 ...

  4. spring核心之AOP学习总结二

    一:springAOP常用的注解 @Aspect:声明方面组件 @Before:声明前置通知 @After-returning:声明后置通知 @After:声明最终通知 @Around:声明环绕通知 ...

  5. oracle 产生随机数

    -- 产生一个任意大小的随机数select dbms_random.random from dual; -- 产生一个100以内的随机数select abs(mod(dbms_random.rando ...

  6. Html5新特性之文档声明和头部信息

    Html5推出的新内容比较多,本文我们来介绍两个重点内容,文档类型声明和头部信息. 无论是Html4.01还是XHtml1.0,所有文档的开头都会有文档声明<!DOCTYPE>标签来声明它 ...

  7. WebSocket、Socket、TCP、HTTP区别

    https://www.cnblogs.com/merray/p/7918977.html

  8. Laravel查询构造器简介

    数据表 CREATE TABLE IF NOT EXISTS students( `id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NO ...

  9. 解决Spring Boot中,通过filter打印post请求的 request body 问题

    http://slackspace.de/articles/log-request-body-with-spring-boot/ (filter + RequestWrapper:最优雅的写法) ht ...

  10. Tomcat catalina-deamon.out 日志切割 每天生成一个文件

    Tomcat 使用 jsvc 以守护进程的方式启动(daemon.sh ).这样tomcat自身将会生成另外一个日志文件(catalina-daemon.out),而不是之前的catalina.out ...