1.准备工作
安装相关的依赖包
yum -y install gcc glibc libaio libstdc libstdc ncurses-libs
查看以前有没有自带的Mysql(如果有的话可以删除my.conf 但是我是另外创建了一个目录)
rpm -qa | grep mysql
普通删除模式
rpm -e mysql
强制删除模式
rpm -e --nodeps mysql
2.基本配置工作
Useradd mysql
groupadd mysql
mkdir –p /usr/local/mysql
mkdir –p /data/4001 #4001端口的数据库存放位置
mkdir –p /data/4003 #4003端口的数据库存放位置
chown –R mysql:mysql /data/4001 #使用者是mysql
chown –R mysql:mysql /data/4003
mkdir –p /etc/mysql_conf/ #存放配置用的
添加环境变量
echo "PATH=$PATH:/usr/local/mysql/bin " >> /etc/profile
使其生效
source /etc/profile
3.下载解压工作
本实例是用的mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
Tar zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
Cd mysql-5.7.9-linux-glibc2.5-x86_64
Mv * /usr/local/mysql #将里面的东西全部移到mysql里面
cp /usr/local/mysql/support-files/my-default.cnf /etc/mysql_conf/4001.conf
cp /usr/local/mysql/support-files/my-default.cnf /etc/mysql_conf/4003.conf
vim /etc/mysql_conf/4001.conf #编辑配置文件
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe #定义多实例路径
mysqladmin = /usr/local/mysql/bin/mysqladmin
[mysqld2]
# GENERAL #
server_id = 4100
relay-log =/data/4001_log/relay-log
basedir = /usr/local/mysql
datadir = /data/4001
port = 4001
socket = /tmp/mysql4001.sock
max_connections = 600
federated = 1
default-storage-engine = InnoDB
character-set-server = utf8
# MyISAM #
key-buffer-size = 32M
# SAFETY #
max-allowed-packet = 16M
max-connect-errors = 100000
read_only = on
# INNODB #
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 512M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 0
innodb-buffer-pool-size = 3G
# LOGGING #
log-error = /data/4001/mysql-error.log
log-queries-not-using-indexes = 1
下面就是初始化数据库 4001
/usr/local/mysql/bin/mysqld --defaults-file=/etc/mysql_conf/4001.conf --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/4001
下面是启动数据库
/usr/local/mysql/bin/mysqld_multi --defaults-extra-file=/etc/mysql_conf/4001.conf start
Cd /tmp
这时候会出现
下面我们就是去初始密码去登录了
mysql -uroot -S /tmp/mysql4001.sock –p
set password = password('#########');
flush privileges;
Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved