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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7.4上2分钟快速安装MySQL5.6相关的知识,希望对你有一定的参考价值。

一、环境介绍:

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

[[email protected]_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初始化报错一

[[email protected]_82_178_centos local]# cd /usr/local/mysql/scripts
报错如下:
[[email protected]_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
[[email protected]_82_178_centos scripts]# 

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

yum -y install autoconf   

2.2初始化报错二

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

[[email protected]_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

登录MySQL给mysql初步优化:

drop database test;drop user ro[email protected]‘::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,tmp,binlog,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 [email protected]‘::1‘;drop user ‘‘@‘localhost‘;drop user ‘‘@‘localhost.localdomain‘;drop user ‘root‘@‘localhost.localdomain‘; select user,host from mysql.user; flush privileges;

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

以上是关于CentOS7.4上2分钟快速安装MySQL5.6的主要内容,如果未能解决你的问题,请参考以下文章

mysql5.7和mysql5.6同在CentOS7.4安装差异对比之5.6.40

3分钟内快速部署MySQL5.6.35数据库实践

mysql5.7和mysql5.6同在CentOS7.4安装差异对比之5.7.18

mysql5.6.35 二进制快速安装

mysql5.6.35 二进制快速安装

mysql5.6快速安装及参数详解