mac 安装mysql@5.7 (brew 安装配置)

1.安装后第一次设置root 以及初始化配置(/usr/local/opt/mysql@5.7/bin目录下)
   mysql_secure_installation
2.链接数据库
    mysql -uroot
3.设置环境变量
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
4.加载环境变量配置
 exec zsh
5.启动mysql
brew services start mysql@5.7

或者

/usr/local/opt/mysql@5.7/bin/mysql.server start
6.进入任意目录

如下则证明成功

☁  ~  mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.23 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> 
7.基本操作
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> use mysql;
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| engine_cost               |
| event                     |
| func                      |
| general_log               |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
31 rows in set (0.00 sec)

mysql> select  host, user from user limit 1 \G;
*************************** 1. row ***************************
host: localhost
user: mysql.sys
1 row in set (0.00 sec)

ERROR: 
No query specified

mysql> 
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页