-
create database test_db; 创建名为test_db数据库
-
use test_db; 进入test_db数据库
-
show tables; 查看数据库里有多少张表
-
drop database test_db ; 删除数据库
-
drop table test01 ; 删除表
-
delete from test01 ; 清空表内容
-
show variables like '%char%'; 查看数据库字符集
-
insert into test01 values ("001","jf1"); 向表中插入数据。
-
select * from test01; 查看test01表数据内容。
-
create table test01 (id varchar(20),name varchar(20));
-
grant all privileges on test_db.* to test@localhost identified by '123456';
-
grant all on test_db.* to test@localhost identified by '123456';
-
grant select,insert,update,delete on *.* to test@”%” identified by ‘123456’;给mysql数据库授权。
-
flush privileges;刷新权限
-
mysqldump –uroot –p123456 test_db >/tmp/test.db.sql ;MySQL备份或导出
-
mysql –uroot –p123456 test_db < /tmp/test.db.sql ;MySQL导入
-
mysqladmin –uroot –p123456 password newpassword ;修改MySQL root密码
-
drop database test_db ; 删除数据库
-
drop table test01 ; 删除表
-
delete from test01 ; 清空表内容
-
show variables like '%char%'; 查看数据库字符集
-
insert into test01 values ("001","ds"); 向表中插入数据。
-
select * from test01; 查看test01表数据内容。
-
create table test01 (id varchar(20),name varchar(20));
-
alter table ip_can drop id;删除某一字段
alter table ip_can add id varchar(20);增加某一字段
alter table ip_can add id varchar(20) first;增加字段在第一行 -
alter table active_user change city city varchar(25); 修改表中某一字段
-
insert into ip_can(user_id,city_id,city,ip) values(1,1,1,1);指定插入字段数据
-
ALTER TABLE ip_can CHANGE `id` `id` INT(8) NOT NULL PRIMARY KEY AUTO_INCREMENT修改表中id为主键并自动增加
-
truncate table ip_can;初始化表是id从1开始记录
-
ALTER TABLE ip_can AUTO_INCREMENT = 1;设置id记录从一开始记录
后续持续更新中
http://blog.163.com/jun_ai_ni_1314/blog/static/1378480552010426112233123/
本文转自 Anonymous123 51CTO博客,原文链接:http://blog.51cto.com/woshitieren/1681211