创建数据库
- 新建1个数据库
create database test_db;
- 授权用户权限;
grant all on test_db.* to 'user'@'host' idedntified by 'Paaswd#2019';
创建基本表
- 新建一个数据表
use test_db;
create table movie (
id char(10) primary key,
movie_name char(20),
movie_star float(1),
movie_people int,
movie_time char(20),
movie_country char(10)
);
- 查看新创建的数据表
show columns from movie;
导入数据
load data local infile '/home/use/move.csv'
into table movie
fields terminated by ','
lines terminated by '\n'
ignore 1 rows;
如果出现secure-file-priv相关的提示需要手动设置secure-file-priv;
sudo vi /etc/my.cnf
# 添加
secure-file-priv=""
#NULL表示限制mysql不允许导入导出,/tmp表示只允许导入导出到/tmp目录,为空时表示不限制mysql导入导出到任意目录
# 重启mysql服务
sudo systemctl restart mysqld

查看导入的数据
select * from movie where id=1;