1、$brew install mysql #源安装
2、$ brew services list
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Name Status User Plist
mysql stopped
3、$ brew services start mysql
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
4、$ mysql -u root
5、mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
6、mysql> create database employment;
Query OK, 1 row affected (0.04 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| employment |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
7、mysql> use employment
Database changed
8、mysql> show tables;
Empty set (0.00 sec)
9、mysql> create table employee(id int,name char(10),time int, salary int)
-> ;
Query OK, 0 rows affected (0.14 sec)
10、mysql> show tables
-> ;
+----------------------+
| Tables_in_employment |
+----------------------+
| employee |
+----------------------+
1 row in set (0.00 sec)
11、mysql> insert into employee values(4,'tang',4,3000)
-> ;
Query OK, 1 row affected (0.12 sec)
12、mysql> select * from employee;
+------+-------+------+--------+
| id | name | time | salary |
+------+-------+------+--------+
| 1 | wang | 2 | 1000 |
| 2 | zhang | 2 | 1000 |
| 4 | tang | 4 | 3000 |
+------+-------+------+--------+
3 rows in set (0.00 sec)
13、mysql> update employee set name = 'li' where id = 1
-> ;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
14、mysql> select * from employee where id = 1;
+------+------+------+--------+
| id | name | time | salary |
+------+------+------+--------+
| 1 | li | 2 | 1000 |
+------+------+------+--------+
1 row in set (0.00 sec)