linux 使用的版本是centos 7,为方便起见,先把防火墙关闭,配置好网络,在安装部分,会分成两部分讲,首先讲单实例安装,也就是一台服务器上就装一个MysqL,接下来就多实例安装,在一个服务器上安装2个甚至多个MysqL.
1.2. 单实例安装
cp /soft/MysqL-5.7.9-linux-glibc2.5-x86_64.tar.gz /usr/local/
解压MysqL到/usr/local目录
解压:
tar -zxvf MysqL-5.7.9-linux-glibc2.5-x86_64.tar.gz
安装需要的依赖
yum install -y libaio
具体安装
shell> groupadd MysqL
shell> useradd -r -g MysqL MysqL
shell> cd /usr/local
shell> tar zxvf /path/to/MysqL-VERSION-OS.tar.gz
shell> ln -s full-path-to-MysqL-VERSION-OS MysqL
shell> cd MysqL
shell> mkdir MysqL-files
shell> chmod 770 MysqL-files
shell> chown -R MysqL .
shell> chgrp -R MysqL .
shell> bin/MysqLd --initialize --user=MysqL # MysqL 5.7.6 and up
shell> bin/MysqL_ssl_rsa_setup # MysqL 5.7.6 and up
shell> chown -R root .
shell> chown -R MysqL data MysqL-files
shell> bin/MysqLd_safe --user=MysqL &
# Next command is optional
shell> cp support-files/MysqL.server /etc/init.d/MysqL.server
配置环境变量:
export PATH=/usr/local/MysqL/bin:$PATH
配置开启启动
chkconfig MysqL.server on
chkconfig --List
登陆,修改密码
set password = ‘root1234%‘;
允许远程登陆
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root1234%‘
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root1234%‘ WITH GRANT OPTION;
flush privileges;
启动的时候可能会报错
这是因为MysqL启动的时候需要配置文件,而在安装centos的时候,哪怕是mini版本都会有个默认的配置在/etc目录中
/usr/local/MysqL/bin/MysqLd --verbose --help |grep -A 1 ‘Default options‘
Default options are read from the following files in the given order:
/etc/my.cnf /etc/MysqL/my.cnf /usr/local/MysqL/etc/my.cnf ~/.my.cnf
MysqL启动的时候会以上面所述的顺序加载配置文件
如果报错,先重命名my.cnf文件
1.3. 多实例安装
以前一些很low的方法是,解压两个MysqL,分别放到不同文件夹,其实在MysqL中已经考虑到了多实例安装的情况。也有相应的脚本命令的支持。
现在要求装两个MysqL 一个3307,3308
新建 /etc/my.cnf 配置如下
[MysqLd]
sql_mode = "STRICT_TRANS_tableS,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_divISION_BY_ZERO,NO_auto_CREATE_USER"
[MysqLd_multi]
MysqLd = /usr/local/MysqL/bin/MysqLd_safe
MysqLadmin = /usr/local/MysqL/bin/MysqLadmin
log = /var/log/MysqLd_multi.log
[MysqLd1]
server-ID = 11
socket = /tmp/MysqL.sock1
port = 3307
datadir = /data1
user = MysqL
performance_schema = off
innodb_buffer_pool_size = 32M
skip_name_resolve = 1
log_error = error.log
pID-file = /data1/MysqL.pID1
[MysqLd2]
server-ID = 12
socket = /tmp/MysqL.sock2
port = 3308
datadir = /data2
user = MysqL
performance_schema = off
innodb_buffer_pool_size = 32M
skip_name_resolve = 1
log_error = error.log
pID-file = /data2/MysqL.pID2
创建2个数据目录
mkdir /data1
mkdir /data2
chown MysqL.MysqL /data{1..2}
MysqLd --initialize --user=MysqL --datadir=/data1
MysqLd --initialize --user=MysqL --datadir=/data2
cp /usr/local/MysqL/support-files/MysqLd_multi.server /etc/init.d/MysqLd_multID
配置开机启动
chkconfig MysqLd_multID on
查看状态
MysqLd_multi report
这个时候发现还需要perl的环境,安装
yum -y install perl perl-devel
在运行,发现已经有实例了
MysqLd_multi report
MysqLd_multi start
启动,分别修改密码,允许远程连接
MysqL -u root -S /tmp/MysqL.sock1 -p -P3307
MysqL -u root -S /tmp/MysqL.sock2 -p -P3308
set password = ‘root1234%‘;
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root1234%‘;
flush privileges;
总结以上是内存溢出为你收集整理的Linux上安装MySQL全部内容,希望文章能够帮你解决Linux上安装MySQL所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)