1 首先下载yum 库。本次基于centos6.10 对应下载地址https://dev.mysql.com/get/mysql80-community-release-el6-2.noarch.rpm
2 默认是8.0版本,更改版本,yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql56-community
3 核对可以版本 yum repolist enabled | grep mysql
4 sudo yum install mysql-community-server
自动安装完毕,启动。service msyqld start 根据提示设置密码,清除测试账户及数据库。
5 变更数据库存储目录
A: service mysqld stop ,停止数据库服务。vim /etc/my.cnf 更改配置文件
#datadir=/var/lib/mysql
datadir=/mnt/sdc/mysql
#socket=/var/lib/mysql/mysql.sock
socket=/mnt/sdc/mysql/mysql.sock
skip-name-resolve
[client]
port = 3306
socket = /mnt/sdc/mysql/mysql.sock
B: cp -a /var/lib/mysql /mnt/sdc/ 拷贝数据库文件 至新的目录。做软连接 ln -s /mnt/sdc/mysql/mysql.sock /var/lib/mysql/mysql.sock 不然程序连接不上去。
C: 如果用程序连接。要建立'root'@'::1'用户。
6 创建用户授权 CREATE USER user01@'localhost' IDENTIFIED BY 'password1';
grant GRANT ALL PRIVILEGES ON *.* TO user01 identified by 'paasword1';
注意每个用户和@后面的地址关联,局域网访问用user@'192.168.0.%' 表示;
7 建库 建表 create database tickdata; CREATE TABLE `reftable` (
`row_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`date` date DEFAULT NULL,
`time` time DEFAULT NULL,
`insid` char(31) DEFAULT NULL,
`price` float DEFAULT NULL,
`vol` int(11) DEFAULT NULL,
`bidprice` float DEFAULT NULL,
`bidvol` int(11) DEFAULT NULL,
`askprice` float DEFAULT NULL,
`askvol` int(11) DEFAULT NULL,
`avprice` float DEFAULT NULL,
`openinst` int(11) DEFAULT NULL,
PRIMARY KEY (`row_id`)
) ;
create database KbarMin1;create database Kbar_day;
CREATE TABLE `reftable` (
`row_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`date` date DEFAULT NULL,
`time` time DEFAULT NULL,
`insid` char(31) DEFAULT NULL,
`oprice` float DEFAULT NULL,
`hprice` float DEFAULT NULL,
`lprice` float DEFAULT NULL,
`cprice` float DEFAULT NULL,
`opinst` int(11) DEFAULT NULL,
`vol` int(11) DEFAULT NULL,
`num` smallint(6) DEFAULT NULL,
PRIMARY KEY (`row_id`)
);