MySQL Mac 安装与简单配置
本文最后更新于:2021年1月6日 晚上
homebrew安装mysql
使用brew命令安装mysql1
mb:~ rustfisher$ brew install mysql
启动停止mysql服务
启动服务 mysql.server start
安装时没有设置密码,可以直接mysql -uroot
登入。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19mb:~ rustfisher$ mysql.server start
Starting MySQL
. SUCCESS!
mb:~ rustfisher$ mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.12 Homebrew
Copyright (c) 2000, 2018, 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> exit;
Bye
输入mysql指令遇到错误1
2mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
指令输入错误,修正一下1
2
3
4
5
6
7
8
9
10mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
停止mysql服务的命令 mysql.server stop
1
2
3mb:anindexserver rustfisher$ mysql.server stop
Shutting down MySQL
... SUCCESS!
简单操作
更改密码
1 |
|
设定了密码后,登录需要输入密码1
2
3
4mb:anindexserver rustfisher$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
参考:
可视化工具 mysql workbench
官方文档请参考 https://dev.mysql.com/downloads/workbench/
mysql workbench 需要primary key
需要有primary key才能编辑内容
https://stackoverflow.com/questions/10815029/mysql-workbench-edit-table-data-is-read-only
配置文件
mac中配置文件默认路径为 /usr/local/etc/my.cnf
可以修改port。1
2
3
4
5# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
port=9527
bind-address = 127.0.0.1
这里限制了连接的端口。
参考: https://www.cyberciti.biz/faq/change-default-mysql-port-under-linuxunix/