抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

介绍 Mac 安装 Mysql 与 mysql 在 mac 在的命令

1. brew install

1
brew install mysql

在mac下使用 brew 安装 mysql,之前没有使用过,今天启动的时候发现启动不了

1
2
3
# /usr/local/bin [9:31:54]
➜ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
1
2
➜ brew info mysql
mysql: stable 8.0.12 (bottled)

2. 启动mysql

1
➜ mysql.server start

3. 设置密码

1
mysql_secure_installation

4. 进入mysql

1
mysql -u root -p
1
2
3
4
5
6
7
8
9
10
11
12
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)

mysql>

5. 常用命令

1
2
3
4
5
$ mysql.server start
$ mysql.server restart
$ mysql.server stop
$ mysql.server status
$ mysql -u root -p

Reference

Comments