MySQL服务的启动和停止
方式1:
搜索计算机服务,服务和应用程序,服务,右键MySQL0909,属性,手动(启动or停止)(可以刷新)
方式2:
停止: cmd(管理员模式运行) net stop mysql0909
开启:cmd(管理员模式运行) net start mysql0909
MySQL服务端的登录和退出
登录
方式1: 通过mysql自带的客户端
运行MySQL 5.5 Command Line Client , 输入密码(0909) 只限于root用户
方式2: 通过windows自带的客户端
cmd(管理员模式运行) mysql -h localhost -P 3306 -u root -p0909
登录 : mysql [-h 主机名 -P 端口号] -u 用户名 -p密码
退出
ctrl + c 或者 exit
MySQL的常见命令
-
查看当前所有的数据库
show databases;
-
打开指定的库
use 库名;
-
查看当前库的所有表
show tables;
-
查看其它库的所有表
show tables from 库名;
-
创建一个表
create table 表名( 列名 列类型, 列名 列类型, ··· );
-
查看表结构
desc 表名;
查看MySQL版本的方式
方式1:cmd(管理员模式运行) mysql --version
方式2:cmd(管理员模式运行) mysql -V
方式3:mysql(客户端) select version();
MySQL的语法规范
-
不区分大小写,但建议关键字大写,表名,列名小写
-
每条命令最好用分号结尾
-
每条命令根据需要,可以进行缩进或换行
sELECT * FROM stuInfo;
-
注释
- 单行注释: #注释文字
- 单行注释: -- 注释文字
- 多行注释 /* 注释文字*/