MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。
一、apt-get安装mariadb
1 sudo apt install mariadb-server //重启操作系统
2 sudo mysql_secure_installation //出始化root 密码 帐户配置 3 sudo mysql_install_db 4 sudo mysql 5 set password=password('asd'); //自动创建的用户名root,密码刚才该成了asd: 6 flush privileges; 7 // 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效。
二、启动mariadb
1 #启动 2 systemctl start mariadb 3 # 开机自启动 4 systemctl enable mariadb
三、配置远程登录
1.修改/etc/mysql/mariadb.conf.d/50-server.cnf
文件
sudo deepin-editor /etc/mysql/mariadb.conf.d/50-server.cnf
# 将bind-address = 127.0.0.1改为 bind-address = 0.0.0.0
2.添加支持远程登录的用户
1 # 连接数据库 2 mysql -u root -p 3 # 查看用户 4 use mysql; 5 select host,user from user; 6 # 设置远程登录账户 格式:create user ‘用户名’@’%’ identified by ‘密码’; 7 create user 'jiang'@'%' identified by 'jwc123jiang'; 8 # 授予权限 grant 权限列表 on 数据库名.表名 to '用户名'@'主机名'; 9 grant all privileges on *.* to root@'localhost' identified by 'jwc123root';
"server=localhost;port=3306;database=movie;user=root;CharSet=utf8;"