不想说太多废话,直接开始步骤吧
一、mysql下载地址:
http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/
需要下载 免编译二进制包mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
二、操作流程
tar -zxvf mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz --解压
mv mysql-5.6.38-linux-glibc2.12-x86_64 /usr/local/mysql --移动
1:关闭firewalld
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2:关闭selinux
vi /etc/sysconfig/selinux
将SELINUX修改为DISABLED,即SELINUX=DISABLED
3:创建mysql用户
groupadd -g 27 mysql
useradd -u 27 -g mysql mysql
id mysql --查看用户信息
4:创建相关目录
mkdir -p /data/mysql/{mysql_3306,mysql_3307}
mkdir -p /data/mysql/mysql_3306/{data,log,tmp}
mkdir -p /data/mysql/mysql_3307/{data,log,tmp}
5:更改目录权限
chown -R mysql:mysql /data/mysql/
chown -R mysql:mysql /usr/local/mysql/
6:添加环境变量
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
7:复制my.cnf文件到etc目录
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
8:修改my.cnf(在一个文件中修改即可)
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld_multi]
mysqld = /usr/local/mysql /bin/mysqld_safe
mysqladmin = /usr/local/mysql /bin/mysqladmin
log = /data/mysql/mysqld_multi.log
[mysqld]
user=mysql
basedir = /usr/local/mysql
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld3306]
mysqld=mysqld
mysqladmin=mysqladmin
datadir=/data/mysql/mysql_3306/data
port=3306
server_id=3306
socket=/tmp/mysql_3306.sock
log-output=file
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql_3306/log/slow.log
log-error = /data/mysql/mysql_3306/log/error.log
binlog_format = mixed
log-bin = /data/mysql/mysql_3306/log/mysql3306_bin
[mysqld3307]
mysqld=mysqld
mysqladmin=mysqladmin
datadir=/data/mysql/mysql_3307/data
port=3307
server_id=3307
socket=/tmp/mysql_3307.sock
log-output=file
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql_3307/log/slow.log
log-error = /data/mysql/mysql_3307/log/error.log
binlog_format = mixed
log-bin = /data/mysql/mysql_3307/log/mysql3307_bin
9:初始化3306数据库
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/mysql_3306/data --defaults-file=/etc/my.cnf
10:初始化3307数据库
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/mysql_3307/data --defaults-file=/etc/my.cnf
--初始化有几率失败,FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
--执行命令:yum -y install autoconf --此包安装时会安装Data:Dumper模块
11:查看3306数据库初始化是否成功
cd /data/mysql/mysql_3306/data&&ls
12:设置启动文件
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
13:mysqld_multi进行多实例管理
启动全部实例:/usr/local/mysql/bin/mysqld_multi start
查看全部实例状态:/usr/local/mysql/bin/mysqld_multi report
启动单个实例:/usr/local/mysql/bin/mysqld_multi start 3306
停止单个实例:/usr/local/mysql/bin/mysqld_multi stop 3306
查看单个实例状态:/usr/local/mysql/bin/mysqld_multi report 3306
14:启动全部实例
/usr/local/mysql/bin/mysqld_multi start --启动
/usr/local/mysql/bin/mysqld_multi report --查看是否成功
15:修改密码
--mysql的root用户初始密码是空,所以需要登录mysql进行修改密码,下面以3306为例:
mysql -S /tmp/mysql_3306.sock
update user set password=password('123456') where user='root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
一、mysql下载地址:
http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/
需要下载 免编译二进制包mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
二、操作流程
tar -zxvf mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz --解压
mv mysql-5.6.38-linux-glibc2.12-x86_64 /usr/local/mysql --移动
1:关闭firewalld
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2:关闭selinux
vi /etc/sysconfig/selinux
将SELINUX修改为DISABLED,即SELINUX=DISABLED
3:创建mysql用户
groupadd -g 27 mysql
useradd -u 27 -g mysql mysql
id mysql --查看用户信息
4:创建相关目录
mkdir -p /data/mysql/{mysql_3306,mysql_3307}
mkdir -p /data/mysql/mysql_3306/{data,log,tmp}
mkdir -p /data/mysql/mysql_3307/{data,log,tmp}
5:更改目录权限
chown -R mysql:mysql /data/mysql/
chown -R mysql:mysql /usr/local/mysql/
6:添加环境变量
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
7:复制my.cnf文件到etc目录
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
8:修改my.cnf(在一个文件中修改即可)
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld_multi]
mysqld = /usr/local/mysql /bin/mysqld_safe
mysqladmin = /usr/local/mysql /bin/mysqladmin
log = /data/mysql/mysqld_multi.log
[mysqld]
user=mysql
basedir = /usr/local/mysql
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld3306]
mysqld=mysqld
mysqladmin=mysqladmin
datadir=/data/mysql/mysql_3306/data
port=3306
server_id=3306
socket=/tmp/mysql_3306.sock
log-output=file
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql_3306/log/slow.log
log-error = /data/mysql/mysql_3306/log/error.log
binlog_format = mixed
log-bin = /data/mysql/mysql_3306/log/mysql3306_bin
[mysqld3307]
mysqld=mysqld
mysqladmin=mysqladmin
datadir=/data/mysql/mysql_3307/data
port=3307
server_id=3307
socket=/tmp/mysql_3307.sock
log-output=file
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql_3307/log/slow.log
log-error = /data/mysql/mysql_3307/log/error.log
binlog_format = mixed
log-bin = /data/mysql/mysql_3307/log/mysql3307_bin
9:初始化3306数据库
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/mysql_3306/data --defaults-file=/etc/my.cnf
10:初始化3307数据库
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/mysql_3307/data --defaults-file=/etc/my.cnf
--初始化有几率失败,FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
--执行命令:yum -y install autoconf --此包安装时会安装Data:Dumper模块
11:查看3306数据库初始化是否成功
cd /data/mysql/mysql_3306/data&&ls
12:设置启动文件
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
13:mysqld_multi进行多实例管理
启动全部实例:/usr/local/mysql/bin/mysqld_multi start
查看全部实例状态:/usr/local/mysql/bin/mysqld_multi report
启动单个实例:/usr/local/mysql/bin/mysqld_multi start 3306
停止单个实例:/usr/local/mysql/bin/mysqld_multi stop 3306
查看单个实例状态:/usr/local/mysql/bin/mysqld_multi report 3306
14:启动全部实例
/usr/local/mysql/bin/mysqld_multi start --启动
/usr/local/mysql/bin/mysqld_multi report --查看是否成功
15:修改密码
--mysql的root用户初始密码是空,所以需要登录mysql进行修改密码,下面以3306为例:
mysql -S /tmp/mysql_3306.sock
update user set password=password('123456') where user='root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
mysql数据拷贝:
set global log_bin_trust_function_creators=TRUE;
创建mysql账号:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;