create table 表名 (字段设定列表); mysql> create table name( -> id int auto_increment not null primary key , -> uname char(8), -> gender char(2), -> birthday date ); Query OK, 0 rows affected (0.03 sec) mysql> show tables; mysql> describe name; 注: auto_increment 自增 primary key 主键
8.查看当前mysql状态 show status; 9.查看当前mysql服务器的队列 show processlist; 10.增加记录 insert into name(uname,gender,birthday) values(‘张三‘,‘男‘,‘1971-10-01‘); 11.删除记录 delete from name where uname=‘张三‘; 12.修改记录 update name set birthday=‘1971-01-10‘ where uname=‘张三‘; 13.查询记录 select count(*)from mysql.user; mysql.user 表示mysql库的user表;count(*)表示表中共有多少行。 select * from mysql.db;这个用来查询mysql库的db表中的所有数据,也可以查询单个字段或者多个字段: select db from mysql.db select db,user from mysql.db 同样,在查询语句中也可以使用万能匹配符“%” select*from mysql.db where host like ‘10.0%‘ 9.1 创建用户 user1 只能通过本机 对test库 增删改查 grant select,insert,update,delete on test.* to user1@localhost indentified by "123" 9.2 查询用户 mysql> use mysql; mysql> select host,user,passwd from user; mysql> update user set password=password(‘new_password‘) where user=‘root‘; 9.3 基本操作 mysql> drop table 表名 mysql> drop database 库名; 9.4 备份 [root@localhost ~]# mysqldump -uroot -p‘yourpassword‘ mysql >/tmp/mysql.sql 使用 mysqldump 命令备份数据库,-u 和 -p 两个选项使用方法和前面说的 mysql 同样,而后面的“mysql” 指的是库名,然后重定向到一个文本文档里。备份完后,你可以查/tmp/mysql.sql 这个文件里的内容。 恢复和备份正好相反: root@localhost ~]# mysql -uroot -p‘yourpassword‘ mysql </tmp/mysql.sql 安装博客:http://www.cnblogs.com/xdpxyxy/archive/2012/11/15/2771565.html 基本操作:http://www.cnblogs.com/xdpxyxy/archive/2012/11/16/2773662.html http://www.cnblogs.com/mitnick/p/6284249.html 修改密码http://www.linuxidc.com/Linux/2014-02/96524.htm
mysql
标签:value mit 表名 gen create archive mysql配置 name oca