导航
导航
文章目录
  1. 一、MariaDB 准备
    1. 1.1 下载
    2. 1.2 安装依赖
    3. 1.3 配置文件
  2. 二、安装 MariaDB
    1. 2.1 添加用户组
    2. 2.2 安装
    3. 2.3 开机自启动
  3. 三、设置 MariaDB

CentOS 从二进制版安装配置 Mariadb

一、MariaDB 准备

1.1 下载

根据系统选择相应版本版本,然后下载解压。

# CentOS 7
mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz 

# Debian 8+, Ubuntu 15.04+
mariadb-10.2.6-linux-systemd-x86_64.tar.gz

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

1.2 安装依赖

yum -y install libaio-devel

1.3 配置文件

# 删除旧的
rm -f /etc/my.cnf

# 复制新的
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

二、安装 MariaDB

2.1 添加用户组

groupadd mysql
useradd -g mysql -M -s /sbin/nologin mysql

2.2 安装

tar -zxf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
ln -s mariadb-10.2.6-linux-glibc_214-x86_64 mysql
cd mysql
./scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data

2.3 开机自启动

cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service start mysql

手动启动

export PATH=$PATH:/usr/local/mysql/bin/
echo 'export PATH=$PATH:/usr/local/mysql/bin/' >> .bashrc
mysqld_safe --user=mysql &

三、设置 MariaDB

安全设置

/usr/local/mysql/bin/mysqladmin -u root password '新密码'
/usr/local/mysql/bin/mysqladmin -u root -h s1.dmfy.gov.cn password '新密码'
/usr/local/mysql/bin/mysql_secure_installation

开启远程登录

mysql -uroot -p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '新密码' WITH GRANT OPTION;

解决 MariaDB 中文乱码

https://mariadb.com/kb/en/mariadb/setting-character-sets-and-collations/

vim /etc/my.cnf

[client]
...
default-character-set=utf8
...
[mysql]
...
default-character-set=utf8
...
[mysqld]
...
character-set-server  = utf8
collation-server      = utf8_general_ci
character_set_server  = utf8
collation_server      = utf8_general_ci
...

查看效果

mysql -uroot -p
SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';

https://mariadb.com/kb/en/mariadb/installing-mariadb-binary-tarballs/

支持一下
扫一扫,支持一下