CentOS7 YUM部署安装MariaDB简录

版权声明:本文为原创文章,转载请标明出处。 https://blog.csdn.net/zwjzqqb/article/details/83055352
# 依据《CentOS7实验机模板搭建部署》克隆实验机
HOSTNAME=mysql
hostnamectl set-hostname "$HOSTNAME"
echo "$HOSTNAME">/etc/hostname
echo "$(grep -E '127|::1' /etc/hosts)">/etc/hosts
echo "$(ip a|grep "inet "|grep -v 127|awk -F'[ /]' '{print $6}') $HOSTNAME">>/etc/hosts

# 配置挂载数据盘
mkdir /var/lib/mysql
echo '/dev/sdb1 /var/lib/mysql ext4 defaults 0 0'>>/etc/fstab
mount -a

# 安装mysql并建库
cd /tmp
yum -y install mariadb-server mariadb
sed -i 's/\[mysqld\]/&\ncollation-server=utf8_general_ci/g' /etc/my.cnf
sed -i 's/\[mysqld\]/&\ncharacter-set-server=utf8/g' /etc/my.cnf
# UTF8MB4字符集参数:utf8mb4_general_ci/utf8mb4
systemctl restart mariadb
systemctl enable mariadb
echo -e "select user()\G\nexit"|mysql
mysql
CREATE DATABASE vincent DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
grant all privileges on vincent.* to vincent@localhost   identified by 'vincent';
grant all privileges on vincent.* to vincent@'127.0.0.1' identified by 'vincent';
-- grant all privileges on vincent.* to vincent@'%' identified by 'vincent';
flush privileges;
exit

[TOC]

猜你喜欢

转载自blog.csdn.net/zwjzqqb/article/details/83055352