centos7 安装mariadb 并使root可远程访问

1. 使用yum安装

yum -y install mariadb mariadb-server

2. 启动

systemctl start mariadb

3.设置开机启动

systemctl enable mariadb

4.基本配置

mysql_secure_installation

输入密码,第一次直接回车

Enter current password for root (enter for none): 

设置密码

Set root password? [Y/n]  是否需要设置root密码
New password:  输入密码
Re-enter new password: 再输入密码

是否删除匿名用户

Remove anonymous users? [Y/n] 

是否禁止root远程登录

Disallow root login remotely? [Y/n]   y

是否删除test数据库

Remove test database and access to it? [Y/n] 

是否重新加载权限表

Reload privilege tables now? [Y/n] 

5. 完成 mysql -uroot -ppassword 进入数据库

6. 如果是阿里云服务器 需要添加安全组规则

7. 如依旧不能远程访问,提示无权限

进入mysql

mysql -uroot -ppassword
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH PRIVILEGES;

猜你喜欢

转载自blog.csdn.net/qq_39785489/article/details/87281097