对mysql授权远程访问
grant all privileges on db_name.table_name to cyl@root identified by 'password' with grant option;
//允许cyl@root用户使用password连接到数据库,并有各种权限。
导入sql脚本
source a.sql
导出sql脚本
mysqldump -u root -p [password] db_name > path/××.sql
建立数据库:
create database ×××;
建立表:
create table ××(id int , name char(10), primary key(id));
create table ××(id int primary key, name char(10));
create table ××(id int not null auto_increment primary key);
修改表:
alter table ×× modify id auto_increment;
alter table ×× modify name char(20);
alter table ×× add primary key(id);
重命名表
ALTER TABLE `table_name` RENAME `new_table_neme` ;
表结构
desc table_name;
插入数据
insert into table_name values(....);
insert into table_name(name) values(...);
insert into table_name select * from table_name;
删除表
drop table table_name;
删除数据库
drop database db_name;
删除表中数据
delete from table_name;
对temp表重复的记录删除
select distinct * i nto temp1 from temp;
delete from temp;
insert into temp select * from temp1;
drop table temp1;