CentOS7.4上快速安装MySQL5.6_数据库技术_Linux公社-Linux系统门户网站
手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

CentOS7.4上快速安装MySQL5.6

[日期:2018-08-06] 来源:Linux社区  作者:wujianwei [字体: ]

一、环境介绍:

云主机全新环境安装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;

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

Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx

本文永久更新链接地址https://www.linuxidc.com/Linux/2018-08/153390.htm

linux
相关资讯       CentOS安装MySQL 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款