转载请注明出处:http://blog.youkuaiyun.com/u011569040/article/details/46899081
获取超级权限:
mysql -uroot -p
查看有几个数据库:
show databases;
敲一个命令敲错了,打Esc可以消除这一行,或者打 \c 使命令不起作用;
创建一个数据库:create database xxx;
显示数据库:show databases;
使用某一个数据库:use xxx;
创建一个表:create table xxx(id int(10) primary key auto_increment,name varchar(30),age tinyint(2));
显示里面的表:show tables;
显示一个表的结构:desc xxx;
向表里插入数据: insert into xxx (name,age) values("zhangsan",22);
增加一个字段: alter table user_name add note_name text;
查询表里的内容:select * from student;
备份数据库——myfirstdb到f盘:mysqldump -uroot -p myfirstdb>f:/myfirstdb.sql
删除一个数据库、表:drop database/table xxx;
回复一个数据库里的表:mysql -uroot -p myfirstdb < f:/myfirstdb.sql
在一个空数据库aaa里导入备份的数据库:,即执行myfirstdb.sql里面的命令
创建表并指定字符集:create table user (id int(10) unsigned primary key auto_increment,name va
rchar(60),age tinyint(2)) default character set utf8;