[root@localhost ~]# uname -r
3.10.0-862.el7.x86_64
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[root@localhost src]# tar -zxvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
查看解压过程是否存在报错
[root@localhost src]# echo $?
0
说明:返回0表示解压成功,否则解压失败
[root@localhost src]# mv mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql
[root@localhost src]# ll
total 321176
-rw-r--r-- 1 root root 328882304 Dec 9 2017 mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[root@localhost src]# ll /usr/local/mysql/
5.创建mysql用户和用户组
[root@localhost src]# cd /usr/local/mysql/
[root@localhost mysql]# useradd mysql
6.创建数据库目录/data/mysql
[root@localhost mysql]# mkdir /data/mysql
7.初始化数据库
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/date/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
报错分析:
初始化mysql数据库报这个错,是因为缺少Data::Dumper这个模块
解决办法1:安装aotuconf库
yum -y install autoconf
解决办法2:模糊搜索perl和dumper这两个软件包
[root@localhost mysql]# yum list | grep perl |grep -i dumper
出现4个Dumper相关的软件包,如果在不知道缺少哪个包的前提下,建议依次yum安装每个软件包,然后再执行数据库初始化命令看返回结果再来执行数据库初始化命令,可以从两个方面判断数据库初始化是否成功
a.执行数据库初始化过程出现两个OK
b.执行echo $?返回值是否为0说明:echo $?的作用是检查上一条命令执行状态,成功返回0,失败返回非0
8.复制mysql5.6的配置文件模板
[root@localhost mysql]# cp ./support-files/my-default.cnf /etc/my.cnf
编辑/etc/my.cnf datadir = /data/mysql socket = /tmp/mysql.sock
9.把mysql5.6数据库的启动脚本移动到/etc/init.d/mysqld
编辑数据库启动脚本/etc/init.d/mysqld,修改
basedir=
datadir=
参数为
basedir=/usr/local/mysql
datadir=/data/mysql
在centos7.5上,如果想要把mysql数据库启动脚本加入到系统开机启动,执行下面命令
10.启动MySQL数据库,执行
[root@localhost mysql]# service mysqld start
Starting MySQL.Logging to '/data/mysql/localhost.localdomain.err'.
................. SUCCESS!
或者
[root@localhost mysql]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@localhost mysql]#
此时可查看到mysql数据库进程
[root@localhost mysql]# ps -ef |grep mysqld
查看数据库监控的端口为3306
[root@localhost mysql]# netstat -nlpt
11.从命令行启动mysql服务
[root@localhost mysql]# /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid &
[root@localhost ~]# ps -ef |grep mysqld
root 20630 17325 0 02:09 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
mysql 20767 20630 0 02:09 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock
root 20861 20802 0 02:10 pts/1 00:00:00 grep --color=auto mysqld
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。