1 添加MariaDB软件源
在/etc/yum.repos.d/
目录中添加MariaDB.repo文件
1 2
| cd /etc/yum.repos.d sudo vi MariaDB.repo
|
在文件中编写
1 2 3 4 5 6 7 8 9
| # MariaDB 10.3 CentOS repository list - created 2018-11-24 14:39 UTC # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB #baseurl = http://yum.mariadb.org/10.3/centos7-amd64 baseurl = http://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64 #gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgkey=http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1
|
2 安装MariaDB
1 2 3 4 5
| sudo yum install MariaDB-server MariaDB-client
sudo yum install mariadb-devel
sudo yum install MariaDB-shared
|
3 修改配置文件
修改 /etc/my.cnf.d/server.cnf
在 [mysqld] 标签下方添加
1 2 3 4 5
| init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake
|
修改/etc/my.cnf.d/client.cnf
在 [client] 标签下方添加
1
| default-character-set=utf8
|
修改/etc/my.cnf.d/mysql-clients.cnf
在 [mysql] 标签下方添加
1
| default-character-set=utf8
|
4 启动
设置开机自启
1
| sudo systemctl enable mariadb
|
启动mariadb
1
| sudo systemctl start mariadb
|
5 设置root账号
1
| mysql_secure_installation
|
6 Python客户端依赖
如果需要使用mysql的python客户端库mysqlclient,需要安装一下依赖包:
1 2 3
| sudo yum install python-devel sudo yum install zlib-devel sudo yum install openssl-devel
|