zoukankan      html  css  js  c++  java
  • 安装篇:MySQL系列之一

    环境:CentOS6.9系统安装MariaDB-10.2.15

    一、yum包管理器安装MariaDB-server

    ​ 1)配置yum源(MariaDB官方源)

    [root@centos6 ~]# vim /etc/yum.repos.d/mariadb-10.2.repo
    [mariadb]
    name=MariaDB
    baseurl=http://yum.mariadb.org/10.2/centos6-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    

    ​ 2)安装

    [root@centos6 ~]# yum -y install MariaDB-server
    

    ​ 3)启动服务并测试

    [root@centos6 ~]# service mysql start
    [root@centos6 mysql]# mysql  #连接成功则说明OK!
    

    二、官方二进制包方式安装MariaDB-server

    ​ 1)获取二进制包

    # wget http://sfo1.mirrors.digitalocean.com/mariadb//mariadb-10.2.15/bintar-linux-x86_64/mariadb-10.2.15-linux-x86_64.tar.gz
    

    ​ 2)创建组和用户

    [root@centos6 ~]# groupadd -r -g 27 mysql
    [root@centos6 ~]# useradd -r -u 27 -g 27 -m -d /data/mysqldb -s /sbin/nologin mysql
    

    ​ 3)解压软件包并修改权限

    [root@centos6 ~]# tar xf mariadb-10.2.15-linux-x86_64.tar.gz -C /usr/local/
    [root@centos6 ~]# cd /usr/local/
    [root@centos6 local]# ln -s mariadb-10.2.15-linux-x86_64/ mysql
    [root@centos6 local]# chown -R root:root mysql/
    [root@centos6 local]# setfacl -R -m u:mysql:rwx mysql/
    

    ​ 4)设置环境变量

    [root@centos6 local]# echo "export PATH=/usr/local/mysql/bin:$PATH" >/etc/profile.d/mysql.sh
    [root@centos6 local]# . /etc/profile.d/mysql.sh
    

    ​ 5)初始化数据库

    [root@centos6 local]# cd /usr/local/mysql/  #必须要进入此目录来执行初始化脚本
    [root@centos6 mysql]# scripts/mysql_install_db --datadir=/data/mysqldb/ --user=mysql
    

    ​ 6)提供配置文件

    [root@centos6 mysql]# cp support-files/my-huge.cnf /etc/my.cnf
    [root@centos6 mysql]# sed -i.bak '/[mysqld]/adatadir = /data/mysqldb' /etc/my.cnf
    

    ​ 7)提供启动服务脚本

    [root@centos6 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
    [root@centos6 mysql]# chkconfig --add mysqld
    [root@centos6 mysql]# chkconfig mysqld on
    

    ​ 8)启动并测试

    [root@centos6 mysql]# service mysqld start
    [root@centos6 mysql]# mysql  #连接成功则说明OK!
    

    三、源码编译安装MariaDB-server

    ​ 1)获取源码

    # wget http://ftp.hosteurope.de/mirror/archive.mariadb.org//mariadb-10.2.15/source/mariadb-10.2.15.tar.gz
    

    ​ 2)准备基础环境

    [root@centos6 ~]# yum -y install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake libevent-devel gnutls-devel libaio-devel openssl-devel ncurses-devel libxml2-devel 
    

    ​ 3)创建组和用户

    [root@centos6 ~]# groupadd -r -g 27 mysql
    [root@centos6 ~]# useradd -r -u 27 -g 27 -m -d /data/mysqldb -s /sbin/nologin mysql
    

    ​ 4)编译安装

    [root@centos6 ~]# tar xf mariadb-10.2.15.tar.gz 
    [root@centos6 ~]# cd mariadb-10.2.15
    [root@centos6 mariadb-10.2.15]# cmake . 
    -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
    -DMYSQL_DATADIR=/data/mysqldb/ 
    -DSYSCONFDIR=/etc 
    -DMYSQL_USER=mysql 
    -DWITH_INNOBASE_STORAGE_ENGINE=1 
    -DWITH_ARCHIVE_STORAGE_ENGINE=1 
    -DWITH_BLACKHOLE_STORAGE_ENGINE=1 
    -DWITH_PARTITION_STORAGE_ENGINE=1  
    -DWITHOUT_MROONGA_STORAGE_ENGINE=1 
    -DWITH_DEBUG=0 
    -DWITH_READLINE=1 
    -DWITH_SSL=system 
    -DWITH_ZLIB=system 
    -DWITH_LIBWRAP=0 
    -DENABLED_LOCAL_INFILE=1  
    -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock 
    -DDEFAULT_CHARSET=utf8 
    -DDEFAULT_COLLATION=utf8_general_ci
    [root@centos6 mariadb-10.2.15]# make -j4 && make install
    

    ​ 5)配置环境变量、修改软件安装目录权限

    [root@centos6 ~]# echo "export PATH=/usr/local/mysql/bin:$PATH" >/etc/profile.d/mysql.sh
    [root@centos6 ~]# . /etc/profile.d/mysql.sh
    [root@centos6 ~]# setfacl -R -m u:mysql:rwx /usr/local/mysql/
    

    ​ 7)初始化数据库、提供配置文件、提供服务启动脚本

    [root@centos6 ~]# cd /usr/local/mysql/
    [root@centos6 mysql]# scripts/mysql_install_db --datadir=/data/mysqldb/ --user=mysql --basedir=/usr/local/mysql/
    [root@centos6 mysql]# cp support-files/my-huge.cnf /etc/my.cnf
    [root@centos6 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
    [root@centos6 mysql]# chkconfig --add mysqld
    

    ​ 8)启动并测试

    [root@centos6 mysql]# service mysqld start
    [root@centos6 mysql]# mysql  #连接成功则说明OK!
    

    @_@ 2018.06.04 21:51

  • 相关阅读:
    poj 2104 C
    2015 百度之星初赛 1 2 2015ACM/ICPC亚洲区上海站 codeforces 851
    3.10补
    3.9补
    3.8补
    3.6补
    3.5补
    3.4补
    3.3补
    2.35补
  • 原文地址:https://www.cnblogs.com/L-dongf/p/9135857.html
Copyright © 2011-2022 走看看