windows端:需要在命令行中进入mysql所在的目录下,进入bin目录下:
比如我的路径是在:e:\tmallStudy\mysql\MySQL Server 5.7\bin下输入:
mysql -hlocalhost -uroot -p
-u后面的为用户名名称 -p后面输入密码
显示出这个时证明连接数据库成功
show databases; //显示存在的数据库
use test; //test为相对应的数据库名称,表示使用某个数据库
show tables; //显示此数据库的所有表
desc book; //book为对应的表名称,此命令为展示表的字段详情
create database test; //建数据库。名字为test
create table user(id int(4) not null primary key auto_increment,username char(20)not null,password char(20) not null);
//创建数据库,名为user
insert into user (1,'duoduo','921012'); //插入一条数据
select * from user; //查询所有的信息