连接数据库

Terminal
$mysql -u root -p

退出连接

Terminal
mysql>$ exit;

修改密码

SQL
update mysql.user set authentication_string=password('新密码') where user='用户名' and Host ='localhost';

刷新权限

Terminal
mysql>$ flush privileges;

创建数据库

Terminal
mysql>$ create database [数据库名];

删除数据库

Terminal
mysql>$ drop database [数据库名];

显示所有数据库

Terminal
mysql>$ show DATABASES;

切换数据库

Terminal
mysql>$ use [数据库名称]
Database changed

查看数据库中所有的表

先选中一个数据库,然后才能查看所选中的数据库中的表。

Terminal
mysql>$ show tables;

查看一个表中的内容

Terminal
mysql>$ describe [表名];

License

Author: 海拉鲁的三角

Link: http://localhost:1313/cpp_notes/posts/mysql/cli/

License: MIT

只要学不死,就往死里学