yum安装MariaDB
使用MariaDB Repository Configuration Tool生成yum源:
https://downloads.mariadb.org/mariadb/repositories/#mirror=tuna
创建mariadb.repo文件:
cat > /etc/yum.repos.d/mariadb.repo <<EOF
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
替换为中科大源
http://mirrors.ustc.edu.cn/help/mariadb.html
sed -i 's#yum\.mariadb\.org#mirrors.ustc.edu.cn/mariadb/yum#' /etc/yum.repos.d/mariadb.repo
或者替换为阿里云源
https://developer.aliyun.com/mirror/
sed -i 's#yum\.mariadb\.org#mirrors.aliyun.com/mariadb/yum#' /etc/yum.repos.d/mariadb.repo
安装mariadb
yum install -y MariaDB-server MariaDB-client
启动mariadb服务并设为开机启动
systemctl enable --now mariadb
登录到数据库,此时root账户的密码为空,直接回车即可,退出Mariadb执行exit即可。
mysql -uroot -p
MariaDB [(none)]> show databases;
MariaDB安全配置
https://mariadb.com/kb/en/mysql_secure_installation/
mysql_secure_installation
执行过程
#输入root(mysql)的密码。默认没有,直接回车
Enter current password for root (enter for none):
#是否切换到unix套接字身份验证[Y/n]
Switch to unix_socket authentication [Y/n] n
#是否设置root密码
Change the root password? [Y/n]
#如果选Y,就输入2次密码
New password:
Re-enter new password:
#是否删除匿名用户?(就是空用户),建议删除
Remove anonymous users? [Y/n]
#是否不允许远程root登录
Disallow root login remotely? [Y/n] n
#是否删除test数据库
Remove test database and access to it? [Y/n] n
#是否加载权限使之生效
Reload privilege tables now? [Y/n] y
允许远程登录
mysql -uroot -p123456
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
验证远程登录
mysql -uroot -p123456 -h 192.168.93.12