温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

MariaDB-server的安装方法

发布时间:2021-07-02 17:22:10 来源:亿速云 阅读:200 作者:chen 栏目:开发技术

这篇文章主要讲解了“MariaDB-server的安装方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“MariaDB-server的安装方法”吧!

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

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

  • 三、源码编译安装MariaDB-server

一、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!

感谢各位的阅读,以上就是“MariaDB-server的安装方法”的内容了,经过本文的学习后,相信大家对MariaDB-server的安装方法这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI