1. Prepare user
groupadd -r -g 306 mysql
useradd -r -g 306 -u 306 –d /data/mysql mysql
2. Prepare the data directory
mkdir /data/mysql
chown mysql:mysql /data/mysq
3. Prepare binaries
tar xf mariadb-VERSION-linux-x86_64.tar.gz -C /usr/local
cd /usr/local
ln -sv mariadb-VERSION mysql
chown -R root:root /usr/local/mysql/
4. Prepare the configuration file
cp -b support-files/my-large.cnf /etc/my.cnf
vim /etc/my.cnf
#mysql语句块中添加以下三个选项
[mysqld]
datadir = /data/mysql
innodb_file_per_table = on #在mariadb5.5以上版的是默认值,可不加
skip_name_resolve = on #禁止主机名解析,建议使用
5. Create a data file
cd /usr/local/mysql/
./scripts/mysql_install_db --datadir=/data/mysql --user=mysql
6. Prepare service script, and start the service
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
service mysqld start
#如果有对应的service 文件可以执行下面
cp support-files/systemd/mariadb.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl enable --now mariadb
7.PATH path
echo ‘PATH=/user/local/mysql/bin:$PATH’ > /etc/profile.d/mysql.sh
. /etc/profile.d/mysql.sh
8. Security Initialization
/user/local/mysql/bin/mysql_secure_installation