MySQL 命令

连接:mysql -uroot -p(root 是用户名,-p 后面为空表示下一步再输入密码,也可以直接在这里跟密码,但是是明文显示的,且有些字符在这里会被当作非密码对待)

连接:mysql -h192.168.0.1 -uroot -p(连接远程的,就使用 -h 参数)

退出:Ctrl + C 或者 exit,或者 quit

 

改密码:mysqladmin -uroot -p老密码 password 新密码;

 

show databases;

use 数据库名;

show tables;

show index from 表名;(查看索引)

alter table 表名 add index 索引名(字段列表);(创建索引)

alter table 表名 add unique 索引名(字段列表);(创建唯一键)

alter table 表名 add primary key 索引名(字段列表);(创建主键)

alter table 表名 drop index 索引名;(删除索引)

drop index 索引名 on 表名;(删除索引)