码迷,mamicode.com
首页 > 数据库 > 详细

CentOS7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz文档与启动时失败排查分析

时间:2017-06-21 11:44:55      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:centos7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz

CentOS7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz

提前准备好mariadb-5.5.46-linux-x86_64.tar.gz

[root@localhost ~]# groupadd -r -g 306 mysql                    ###添加mysql用户

[root@localhost ~]# useradd -r -g 306 -u 306 mysql              ###添加mysql组

[root@localhost dylan]# tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local/

[root@localhost dylan]# cd /usr/local/

[root@localhost local]# ln -sv mariadb-5.5.46-linux-x86_64/ mysql    ###创建mysql链接

[root@localhost local]# cd mysql

[root@localhost mysql]# chown -R root.mysql ./*                    ###更改属组属组

[root@localhost mysql]# mkdir -pv /mydata/data                     ###创建数据目录

mkdir: 已创建目录 "/mydata"

mkdir: 已创建目录 "/mydata/data"

[root@localhost mysql]# chown -R mysql.mysql /mydata/data/        ###更改数据目录权限

[root@localhost mysql]# mkdir /etc/mysql

###将选择的配置文件复制至/etc/mysql/中,并重命名为my.cnf

[root@localhost mysql]# cp support-files/my-large.cnf /etc/mysql/my.cnf 

[root@localhost mysql]# vim /etc/mysql/my.cnf                     ###编辑添加

thread_concurrency = 8

datadir = /mydata/data                                            ###设定数据文件目录

innodb_file_per_table = ON                                        

skip_name_resolve = ON                                            ###跳过主机名解析

###复制mysqld的服务管理文件至/etc/rc.d/init.d并命名为mysqld

[root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

[root@localhost mysql]# ls -l /etc/rc.d/init.d/mysqld

-rwxr-xr-x. 1 root root 12196 6月  20 22:28 /etc/rc.d/init.d/mysqld

[root@localhost mysql]# chkconfig --add mysqld                     ###添加服务

###程序初始化,指定用户为mysql,数据目录为/mydata/data

[root@localhost mysql]# scripts/mysql_install_db  --user=mysql --datadir=/mydata/data

[root@localhost mysql]# service mysqld start

Starting MySQL. ERROR!     ###启动错误

###编辑selinux,关闭selinux

[root@localhost mysql]# vim /etc/selinux/config 

SELINUX=disabled

[root@localhost mysql]# getenforce

Enforcing

[root@localhost mysql]# setenforce 0

[root@localhost mysql]# getenforce

Permissive

###此时启动依然出错,mysql读取配置文件不仅仅有一个,mysql进程会以此去找很多个位置,并使用最后的作为最终的配置。

[root@localhost /]# /usr/local/mysql/bin/mysql --help --verbose    ###查看读取次序

/usr/local/mysql/bin/mysql  Ver 15.1 Distrib 5.5.46-MariaDB, for Linux (x86_64) using read

line 5.1Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Usage: /usr/local/mysql/bin/mysql [OPTIONS] [database]

Default options are read from the following files in the given order:

/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf                 ###读取顺序

###于是查看/etc/my.cnf文件,在log-error=/var/log/mariadb/mariadb.log中,于是查看/var/log/中不存在mariadb目录,需手动创建,或者将此注销掉,否则启动服务会失败。

[root@localhost rc.d]# vim /etc/my.cnf                 

[mysqld_safe]

log-error=/var/log/mariadb/mariadb.log ###错误日志路径

pid-file=/var/run/mariadb/mariadb.pid

###查看/var/log/下并没有mariadb目录,于是有三种方法解决:

1.mv /etc/my.cnf  /etc/my.cnf.bak ###使/etc/my.cnf失效

2.vim /etc/my.cnf   

#log-error=/var/log/mariadb/mariadb.log ###注销掉

3.mkdir /var/log/mariadb     ###创建mariadb目录

[root@localhost mysql]# mkdir /var/log/mariadb         ###此处使用第三种方法

[root@localhost mysql]# service mysqld start

Starting MySQL... SUCCESS!     ###成功启动

###修改环境变量

[root@localhost rc.d]# vim /etc/profile.d/mysql.sh

export PATH=/usr/local/mysql/bin:$PATH

[root@localhost rc.d]# source /etc/profile.d/mysql.sh ###重读此配置文件

###导出头文件

[root@localhost rc.d]# ln -sv /usr/local/mysql/include/ /usr/include/mysqld

"/usr/include/mysqld" -> "/usr/local/mysql/include/"

###导出库文件

[root@localhost ld.so.conf.d]# vim /etc/ld.so.conf.d/mysql.conf

/usr/local/mysql/lib

[root@localhost ld.so.conf.d]# ldconfig ###系统重载入系统库

[root@localhost ld.so.conf.d]# ldconfig -p |grep mysql ###查看库文件读取

libmysqld.so.18 (libc6,x86-64) => /usr/local/mysql/lib/libmysqld.so.18

libmysqld.so (libc6,x86-64) => /usr/local/mysql/lib/libmysqld.so

libmysqlclient.so.18 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.18

libmysqlclient.so.18 (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so.18

libmysqlclient.so (libc6,x86-64) => /usr/local/mysql/lib/libmysqlclient.so     

###mysql安全加固

[root@localhost bin]# mysql_secure_installation ###运行此命令进行设置


本文出自 “11290766” 博客,请务必保留此出处http://rylan.blog.51cto.com/11290766/1940437

CentOS7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz文档与启动时失败排查分析

标签:centos7.2通用二进制格式安装mariadb-5.5.46-linux-x86_64.tar.gz

原文地址:http://rylan.blog.51cto.com/11290766/1940437

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!