CentOS7.4上2分鐘快速安裝MySQL5.6
阿新 • • 發佈:2018-08-03
設置 serve hat 腳本 please word cto efault loading 一、環境介紹:
騰訊雲雲主機全新環境安裝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;
介紹完畢,希望可以幫助初級技術人員
CentOS7.4上2分鐘快速安裝MySQL5.6