启动/停止数据库
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start(stop)
连接数据库
bash-3.2# /Applications/XAMPP/xamppfiles/bin/mysql -u root -p
Enter password:
显示所有数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| blog |
| cdcol |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
+--------------------+
7 rows in set (0.01 sec)
选中具体数据库
mysql> use blog;
Database changed
显示当前数据库所有表
mysql> show tables;
+----------------+
| Tables_in_blog |
+----------------+
| blog_user |
+----------------+
1 row in set (0.00 sec)
显示表字段信息
mysql> describe blog_user;
+----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+----------------+
| id | int(11) unsigned | NO | PRI | NULL | auto_increment |
| username | varchar(255) | YES | | | |
| password | varchar(11) | YES | | NULL | |
+----------+------------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
查询数据
mysql> select * from blog_user;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
| 1 | admin | 123456 |
| 2 | root | root |
+----+----------+----------+
2 rows in set (0.00 sec)
插入数据
mysql> insert into blog_user values ("3","kkk","nnn");
Query OK, 1 row affected (0.00 sec)
修改数据
mysql> update blog_user set password="lll" where username='kkk';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
退出
mysql> exit
Bye