第一步:新建用户
先登录进root用户,然后再利用root用户的权限进行创建用户操作
mysql> create user 'test'@'localhost' identified by '888888';
刷新授权:mysql> flush privileges;
为新用户分配权限:mysql> grant all privileges on car.* to test@localhost;
第二步:建表导入数据
CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
然后出现了错误:
mysql> LOAD DATA LOCAL INFILE 'C:UsersAdministratorDesktoppet.txt' INTO TABLE pet; ERROR 1148 (42000): The used command is not allowed with this MySQL version
解决方案
mysql> SHOW VARIABLES LIKE 'local_infile';
状态:ON 结果也还是不行,退出重来
C:UsersAdministrator>mysql --local_infile=1 -u test -p
mysql> LOAD DATA LOCAL INFILE 'C:UsersAdministratorDesktoppet.txt' INTO TABLE pet; ERROR 2 (HY000): File 'C:UsersAdministratorDesktoppet.txt' not found (OS errno 2 - No such file or directory) mysql> LOAD DATA LOCAL INFILE 'C:/Users/Administrator/Desktop/pet.txt' INTO TABLE pet; Query OK, 8 rows affected, 7 warnings (0.11 sec) Records: 8 Deleted: 0 Skipped: 0 Warnings: 7
结果:载入数据成功