l
l
Net start mysql服务名
l
l
Net stop mysql服务名 停止:bin/mysqladmin -uroot shutdown
l
登陆数据库:打开dos窗口
l
mysql -u root -p mysql
l
mysql -uroot -p -P5188 db1 --default-character-set=gbk
l
mysql -h192.168.1.2 -uroot -p --default-character-set=gbk
l
使用数据库:
l
选择数据库:use jwplat;
l
显示数据库列表:show databases;
l
退出mysql
l
quit
l
使用表:
l
显示库中的数据表:show tables;
l
显示数据表的结构:desc 表名;
l
修改口令
l
mysqladmin -uroot -pold password new
l
mysqladmin -uroot -p123 password “” --置空
l
增加新用户
l
grant select,insert,update,delete on *.* to "simon"@"%" Identified by "simon";
l
grant ALL PRIVILEGES on *.* to "simon"@localhostIdentified by "simon";
l
三建四句
l
建库1:create database stu DEFAULT CHARACTER SET GBK ;
l
删除表:DROP TABLE IF EXISTS t2;
l
建表1:create table t11( id1 intnot null PRIMARY KEY AUTO_INCREMENT, d0 FLOAT, d1 DOUBLE,d2 DECIMAL(10,2),c1 CHAR(10), c2 VARCHAR(100), c3 TEXT,b1 blob,birth datetime default NULL) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
l
建表2双主键:Create table t12(id1 int , id2 int, primary key(id1,id2));
l
建表3外键约束:Create table t3(id1 int not null, CONSTRAINT fk1 FOREIGN KEY(id1) REFERENCES t1(id1))ENGINE=InnoDB DEFAULT CHARSET=gb2312;
l
删除外键:alter table t3 DROP FOREIGN KEY fk1;
l
添加外键:alter table t3 add constraint fk1 foreign key(id1) references t1(id1) ;
启动:bin/mysqld
l