MySQL 基本操作(命令行)

  • 新建用户

先登录进root用户,然后再利用root用户的权限进行创建用户操作

mysql> create user 'test'@'localhost' identified by '123456';

刷新授权:mysql> flush privileges;

为新用户分配权限:mysql> grant all privileges on car.* to test@localhost;

  • 建表导入数据(txt)
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:\Users\Administrator\Desktop\pet.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:\Users\Administrator>mysql --local_infile=1 -u test -p
mysql> LOAD DATA LOCAL INFILE 'C:\Users\Administrator\Desktop\pet.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

  载入数据成功

扫描二维码关注公众号,回复: 5779899 查看本文章

 

猜你喜欢

转载自www.cnblogs.com/sece/p/10657230.html