MariaDB的安装与配置

官网地址:http://www.mariadb.com

中文官方文档:https://mariadb.com/kb/zh-cn/

一、YUM安装

查看YUM可安装的版本:http://yum.mariadb.org/

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2.9/centos7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

二、二进制包安装

下载地址:https://downloads.mariadb.org/mariadb/+releases/ 

本人下载包:https://downloads.mariadb.org/interstitial/mariadb-10.2.9/bintar-linux-x86_64/mariadb-10.2.9-linux-x86_64.tar.gz

安装参考文档:https://mariadb.com/kb/en/library/installing-mariadb-binary-tarballs/

# tar -xzf mariadb-10.2.9-linux-x86_64.tar.gz
# mv mariadb-10.2.9-linux-x86_64 /usr/local/mysql

2.1 创建用户和组

# groupadd mysql
# useradd -r -g mysql -s /bin/false mysql #创建系统用户,且无法登录

2.2 更改文件属主

# chown -R mysql:mysql /usr/local/mysql/

2.3 创建my.cnf

# touch /etc/my.cnf && chown -R mysql /etc/my.cnf

[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
log-error=/var/log/mysql/error.log
pid-file=/var/run/mysql/mysql.pid

# mkdir -p /var/log/mysql/ && chown -R mysql:mysql /var/log/mysql/
# mkdir -p /var/run/mysql/ && chown -R mysql:mysql /var/run/mysql/

 2.4 初始化

# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
Tips :切换到 /usr/local/mysql 目录后执行

2.5 初始化完成后,重置回属主

# chown -R root /usr/local/mysql/ 
# chown -R mysql data

2.6 启动

方式一:
# /usr/local/mysql/bin/mysqld_safe --user=mysql &

方式二:(推荐)
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# service mysqld start

2.7 修改root密码

# mysql -u root  -p #首次登录无密码
[MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
[MariaDB [(none)]> flush privileges;

 

注意和Mysql比较:

MariaDB的安装与配置》上有1条评论

  1. Pingback引用通告: MySQL的安装与配置 | 精彩每一天

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>