CentOS7.4上2分钟快速安装MySQL5.6

前端之家收集整理的这篇文章主要介绍了CentOS7.4上2分钟快速安装MySQL5.6前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、环境介绍:

腾讯云云主机全新环境安装MysqL5.6.39

[root@VM_82_178_centos scripts]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)
磁盘伪云盘40G
内存为2G

二、开始安装:

上传my.cnf模板文件到服务器/etc/下
上传文件MysqL-5.6.39-linux-glibc2.12-x86_64.tar.gz到服务器root目录下

useradd MysqL -s /sbin/nologin -M
mkdir /data/MysqL/{data,tmp,binlog,log} -p
chown -R MysqL.MysqL /data/MysqL
tar xf /root/MysqL-5.6.39-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
cd /usr/local/
mv MysqL-5.6.39-linux-glibc2.12-x86_64  MysqL
chown -R MysqL.MysqL /usr/local/MysqL
cd /usr/local/MysqL/scripts

2.1初始化报错一

[root@VM_82_178_centos local]# cd /usr/local/MysqL/scripts
报错如下:
[root@VM_82_178_centos scripts]# ./MysqL_install_db --datadir=/data/MysqL/data --basedir=/usr/local/MysqL --user=MysqL --explicit_defaults_for_timestamp
FATAL ERROR: please install the following Perl modules before executing ./MysqL_install_db:
Data::Dumper
[root@VM_82_178_centos scripts]#

解决方法 :安装autoconf库
命令: yum -y install autoconf //此包安装时会安装Data:Dumper模块

yum -y install autoconf

2.2初始化报错二

重新执行初始化命令再次报错:

[root@VM_82_178_centos scripts]# ./MysqL_install_db --datadir=/data/MysqL/data --basedir=/usr/local/MysqL --user=MysqL --explicit_defaults_for_timestamp
Installing MysqL system tables.../usr/local/MysqL/bin/MysqLd: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

原因是这是缺少numactl。所以直接yum -y install numactl就可以解决这个问题了.

yum -y install numactl

再次初始化MysqL,此时初始化成功

三、准备启动脚本并开启MysqL服务

cp /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqLd
chkconfig MysqLd on
echo "export PATH=$PATH:/usr/local/MysqL/bin" > /etc/profile.d/MysqL.sh
source /etc/profile
/etc/init.d/MysqLd restart
ps -ef|grep MysqL

登录MysqLMysqL初步优化:

drop database test;drop user root@'::1';drop user ''@'localhost';drop user ''@'localhost.localdomain';drop user 'root'@'localhost.localdomain'; select user,host from MysqL.user; flush privileges;

MysqL服务设置登录密码:

MysqLadmin -uroot password '123321123'

到此处安装完成

四、CentOS7.4上MysqL5.6.39快速安装步骤:

useradd MysqL -s /sbin/nologin -M
mkdir /data/MysqL/{data,log} -p
chown -R MysqL.MysqL /data/MysqL
yum -y install autoconf  numactl  libaio-devel 
tar xf /root/MysqL-5.6.39-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
cd /usr/local/
mv MysqL-5.6.39-linux-glibc2.12-x86_64  MysqL
chown -R MysqL.MysqL /usr/local/MysqL
cd /usr/local/MysqL/scripts
./MysqL_install_db --datadir=/data/MysqL/data --basedir=/usr/local/MysqL --user=MysqL --explicit_defaults_for_timestamp
cp /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqLd
chkconfig MysqLd on
echo "export PATH=$PATH:/usr/local/MysqL/bin" > /etc/profile.d/MysqL.sh
source /etc/profile
/etc/init.d/MysqLd restart
ps -ef|grep MysqL

MysqLadmin -uroot password '123321123' 

MysqL -uroot -p'123321123'
MysqL初步优化:
drop database test;drop user root@'::1';drop user ''@'localhost';drop user ''@'localhost.localdomain';drop user 'root'@'localhost.localdomain'; select user,host from MysqL.user; flush privileges;

介绍完毕,希望可以帮助初级技术人员

原文链接:https://www.f2er.com/centos/374107.html

猜你在找的CentOS相关文章