MySQL系列之一 MariaDB-server安装

吾爱主题 阅读:129 2024-04-02 08:03:52 评论:0

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

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

?
1 2 3 4 5 6 [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)安装

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

​ 3)启动服务并测试

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

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

1)获取二进制包

?
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)创建组和用户

?
1 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)解压软件包并修改权限

?
1 2 3 4 5 [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)设置环境变量

?
1 2 [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)初始化数据库

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

​ 6)提供配置文件

?
1 2 [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)提供启动服务脚本

?
1 2 3 [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)启动并测试

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

三、源码编译安装MariaDB-server

1)获取源码

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

​ 2)准备基础环境

?
1 [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)创建组和用户

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

​ 4)编译安装

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [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)配置环境变量、修改软件安装目录权限

?
1 2 3 [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)初始化数据库、提供配置文件、提供服务启动脚本

?
1 2 3 4 5 [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)启动并测试

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

到此这篇关于MySQL系列之一 MariaDB-server安装的文章就介绍到这了,更多相关MySQL MariaDB-server安装内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://www.cnblogs.com/L-dongf/p/9135857.html

可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

【腾讯云】云服务器产品特惠热卖中
搜索
标签列表
    关注我们

    了解等多精彩内容