一、环境介绍:
腾讯云云主机全新环境安装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 -Mmkdir /data/mysql/{data,tmp,binlog,log} -pchown -R mysql.mysql /data/mysqltar 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 mysqlchown -R mysql.mysql /usr/local/mysqlcd /usr/local/mysql/scripts
[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_timestampFATAL 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
重新执行初始化命令再次报错:
[root@VM_82_178_centos scripts]# ./mysql_install_db --datadir=/data/mysql/data --basedir=/usr/local/mysql --user=mysql --explicit_defaults_for_timestampInstalling 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,此时初始化成功
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchkconfig mysqld onecho "export PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.shsource /etc/profile/etc/init.d/mysqld restartps -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‘
到此处安装完成
useradd mysql -s /sbin/nologin -Mmkdir /data/mysql/{data,tmp,binlog,log} -pchown -R mysql.mysql /data/mysqlyum -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 mysqlchown -R mysql.mysql /usr/local/mysqlcd /usr/local/mysql/scripts./mysql_install_db --datadir=/data/mysql/data --basedir=/usr/local/mysql --user=mysql --explicit_defaults_for_timestampcp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchkconfig mysqld onecho "export PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.shsource /etc/profile/etc/init.d/mysqld restartps -ef|grep mysqlmysqladmin -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;
介绍完毕,希望可以帮助初级技术人员