MySQL是一款轻量级的关系数据库。
ubuntu安装MySQL
root@ubuntu:~# sudo apt-get install mysql-server
root@ubuntu:~# apt isntall mysql-client
root@ubuntu:~# apt install libmysqlclient-dev
ubuntu安装MySQL可视化
个人感觉在ubuntu上比较好用的Mysql可视化程序是MySQL Workbench
安装MySQL Workbench过程:
在安装好Mysql后,输入以下命令。
sudo apt-get install mysql-workbench
MySQL一些基本操作
创建数据库,并设置中文字符编码
CREATE DATABASE database_name CHARACTER SET utf8;
USE database_name;
修改数据编码
ALTER DATABASE database_name CHARACTER SET utf8;
删除数据库
DROP DATABASE database_name;
创建数据表
CREATE TABLE table_name(
tutorial_id INT NOT NULL AUTO_INCREMENT,
tutorial_title VARCHAR(100) NOT NULL,
tutorial_author VARCHAR(40) NOT NULL,
submission_date DATA,
PRIMARY KEY (tutorial_id)
);
删除表
DROP TABLE table_name;
向mysql中插入csv文件数据
alter database NLPData character set utf8mb4 collate utf8mb4_unicode_ci;
create table emission(
id int not null auto_increment,
characters varchar(4) not null,
pinyin varchar(32) not null,
probability float4,
primary key(id)
);
alter table emission character set utf8 collate utf8_unicode_ci;
load data infile '/var/lib/mysql-files/emission.csv'
into table emission
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
ignore 1 rows;
(未完待续……)