Mac下Mysql启动异常["ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"]
2016-07-25 11:42
691 查看
在mac下使用brew安装mysql,之前没有使用过,今天启动的时候发现启动不了
查看mysql的安装位置:
说明mysql还是安装过的
有可能是mysql服务没有启动
哈哈,mysql服务启动了,好开心呀!
接下来要试试能否进入mysql了
这个提示应该很明显了吧,权限问题,mysql下没有huijunzhang这个用户,装过mysql的朋友应该知道,安装mysql默认的用户名是root,端口是3306,别问我为什么知道。。。
那就使用root用户启动:
哈哈,问题解决了,好开心呀!
总结:出现“ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)”的根本原因就是mysql服务没有启动,下面总结下mysql在mac下的几个常用的命令吧!
huijundeMacBook-Pro:bin huijunzhang$ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
查看mysql的安装位置:
huijundeMacBook-Pro:bin huijunzhang$ which mysql /usr/local/bin/mysql
说明mysql还是安装过的
huijundeMacBook-Pro:bin huijunzhang$ brew info mysql mysql: stable 5.7.13 (bottled) Open source relational database management system https://dev.mysql.com/doc/refman/5.7/en/ Conflicts with: mariadb, mariadb-connector-c, mysql-cluster, mysql-connector-c, percona-server /usr/local/Cellar/mysql/5.7.13 (13,344 files, 445.0M) * Poured from bottle on 2016-06-30 at 15:05:40 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb ==> Dependencies Build: cmake ✘ Required: openssl ✔ ==> Options --with-archive-storage-engine Compile with the ARCHIVE storage engine enabled --with-blackhole-storage-engine Compile with the BLACKHOLE storage engine enabled --with-debug Build with debug support --with-embedded Build the embedded server --with-local-infile Build with local infile loading support --with-test Build with unit tests ==> Caveats We've installed your MySQL database without a root password. To secure it run: mysql_secure_installation To connect run: mysql -uroot To have launchd start mysql now and restart at login: brew services start mysql Or, if you don't want/need a background service you can just run: mysql.server start
有可能是mysql服务没有启动
huijundeMacBook-Pro:bin huijunzhang$ mysql.server start Starting MySQL . SUCCESS!
哈哈,mysql服务启动了,好开心呀!
接下来要试试能否进入mysql了
huijundeMacBook-Pro:bin huijunzhang$ mysql ERROR 1045 (28000): Access denied for user 'huijunzhang'@'localhost' (using password: NO)
这个提示应该很明显了吧,权限问题,mysql下没有huijunzhang这个用户,装过mysql的朋友应该知道,安装mysql默认的用户名是root,端口是3306,别问我为什么知道。。。
那就使用root用户启动:
huijundeMacBook-Pro:bin huijunzhang$ sudo mysql Password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.13 Homebrew Copyright (c) 2000, 2016, 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> mysql> show databases -> ; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec)
哈哈,问题解决了,好开心呀!
总结:出现“ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)”的根本原因就是mysql服务没有启动,下面总结下mysql在mac下的几个常用的命令吧!
$ mysql.server start $ mysql.server restart $ mysql.server stop $ mysql.server status $ mysql -u root -p
相关文章推荐
- Win7 64位 MySQL 5.6下载、安装与配置:
- mysql中各个模块如何协同工作
- MySql 数据库部分字段区分大小写
- 利用Navicat实现MySQL数据库结构对比和同步
- Ubuntu ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
- mysql 最大显示宽度关系
- mysql本地部署并通过jdbc连接的操作步骤
- mysql按月获取一年内每个月的数据量
- MySQL命令行导入sql数据库
- mysql中innodb和myisam详解
- Mysql命令大全
- win7 64位,PowerDesigner中导入MYSQL数据库结构的步骤及问题解决
- .NET高性能框架Chloe.ORM-完美支持MySql
- MySQL存储过程
- Mysql中查询系统时间
- mysql max_allowed_packet 设置过小导致记录写入失败
- Mysql 关键字-保留字
- mysql常用函数汇总(分享)
- MySQL 事件跟踪器 , MySQL 无须重启服务 跟踪 SQL , 也无须配置日志
- jdbc连接MySQL数据库