启动和停止mysql
最基本启动器和停止工具是mysql的bin里面的mysqld,该工具是二进制的,语法为mysqld start或者mysqld stop。如果使用service mysqld start或者bin里面的mysqld_safe启动,本质都是调用了mysqld,只是加了一些其他的处理。
创建和删除用户
grant all privileges on *.* to it@"%" identified by "itpwd" with grant option;
grant all privileges on *.* to it@"localhost" identified by "itpwd" with grant option;
据说执行第一条就能任意主机访问了,但是我得执行上面两条才生效。
删除比较简单,drop user it;
建表详细语句
CREATE TABLE `topic` (
`TopicId` int(50) NOT NULL auto_increment,
`Topic_BoardId` int(10) NOT NULL,
`Topic_StudentId` int(10) NOT NULL,
`TopicTitle` varchar(1000) NOT NULL,
`TopicContent` varchar(6000) NOT NULL,
`TopicSendTime` varchar(30) NOT NULL,
PRIMARY KEY (`TopicId`),
FOREIGN KEY (`Topic_BoardId`) REFERENCES `board` (`BoardId`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`Topic_StudentId`) REFERENCES `student` (`StudentId`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=gb2312
修改密码
mysqladmin -u root -p password 123456
会提示输入旧密码
注意:linux下执行这个语句,需要OS的root权限。有时候想用sudo来实现,但是sudo后只让输入一次密码,搞不懂该算是OS的root密码还是mysql的root密码,总之会失败。可以先用sudo执行一条其他的OS语句,输入OS的root密码后root状态会保持一段时间,这段时间内直接执行mysqladmin -u root -p password 123456就行了。
导出csv
select * from table1
INTO OUTFILE 'c:/xxx.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '/n'
导入csv
LOAD DATA INFILE 'data.txt' INTO TABLE table2
FIELDS TERMINATED BY ',';
;