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

登录MySQL给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;

给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 root@'::1';drop user ''@'localhost';drop user ''@'localhost.localdomain';drop user 'root'@'localhost.localdomain'; select user,host from mysql.user; flush privileges;

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

相关文章
相关标签/搜索