背景:因为公司后台人员告诉我物理数据库经常受到攻击,所以我们需要将数据库紧急迁到云上。由于我自己曾经购买了云,所以我的云自然成了救命稻草。opensuse的稳定性(德国佬做的,你说呢???)是我用过的最好的,因此我们选择了opensuse系统
条件:首先我们需要一台云服务器,并将其装上opensuse15.1系统
环境配置:
- 安装mariadb:
这个mariadb包括服务端,客户端,一件安装即可sudo zypper install mariadb
- 启动mariadb:
systemctl start mariadb
- 设置开机启动:
systemctl enable mariadb
建立用户,并设置好远程连接:
- 创建用户:
create user username@localhost identified by 'password';
- 赋予此用户远程连接的权限:
grant all privileges on *.* to username@'%' identified by 'password';
- 设置阿里云的安全组:如图所示,我设置端口3306和所有IP可访问,如果你需要更高的安全性,可以设置指定IP地址才能访问
- 打开mariadb的远程访问权限,mariadb的配置文件/etc/my.cnf
vim /etc/my.cnf
然后会有一行
bind-address = 127.0.0.1
将其注释掉就代表允许所有ip访问,或者你可以设置指定ip
这样,环境就配置好了。