共计 3249 个字符,预计需要花费 9 分钟才能阅读完成。
一、环境介绍:
服务器云主机全新环境安装 MySQL5.6.39
[root@linuxmi_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@linuxmi_centos local]# cd /usr/local/mysql/scripts
报错如下:
[root@linuxmi_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@linuxmi_centos scripts]#
解决方法:安装 autoconf 库
命令: yum -y install autoconf // 此包安装时会安装 Data:Dumper 模块
yum -y install autoconf
2.2 初始化报错二
重新执行初始化命令再次报错:
[root@linuxmi_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;
介绍完毕,希望可以帮助初级技术人员。
更多 MySQL 相关教程见以下内容:
MySQL 多实例安装 https://www.linuxidc.com/Linux/2018-07/153254.htm
CentOS7.4 上快速安装 MySQL5.6 https://www.linuxidc.com/Linux/2018-08/153390.htm
CentOS 7 源码编译安装 MySQL 8.0 https://www.linuxidc.com/Linux/2018-06/152859.htm
SUSE Linux 11 安装 MySQL5.7.22:二进制安装方式、单实例 https://www.linuxidc.com/Linux/2018-08/153351.htm
在 CentOS Linux 7.5 上安装 MySQL https://www.linuxidc.com/Linux/2018-05/152574.htm
CentOS 7 安装 MySQL 5.7.18 过程笔记 https://www.linuxidc.com/Linux/2018-08/153524.htm
CentOS 7.5 下安装单实例 MySQL 5.7 https://www.linuxidc.com/Linux/2018-08/153468.htm
: