一、安装mariadb数据库
yum -y install mariadb mariadb-server
二、启动数据库服务
service mariadb start
三、查看运行状态
service mariadb status
设置密码
mysqladmin password # 修改密码mysqladmin -p password
登录数据库
mysql -uroot -p
create user 'qgs'@'%' identified by 'qgs111'; #create user '用户名'@'%' identified by '密码';
grant select,process,super on *.* to 'qgs'@'%' identified by 'qgs111'; #grant select,process,super on *.* to '用户名'@'%' identified by '密码'; 允许所有ip连接(用通配符%表示),只允许指定IP地址链接将%去掉即可
flush privileges;
create database qgs_db default character set 'utf8'; #创建名称为“ aqgs_db”的数据库
grant all privileges on qgs_db.* to 'qgs'@'localhost'; #将库“ qgs_db”的所有权限授予用户“ qgs”
flush privileges;
quit
数据库可能也会链接不上,那就
解决方法1
关闭防火墙
systemctl disable --now firewalld
或防火墙“ firewalld”中开启公网访问Mariadb数据库3306端口
systemctl restart firewalld
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
解决方法2
或者初始化数据库,初始化后就只能重新添加用户之类的之前操作
mysql_secure_installation #初始化 mariadb 并配置 root 密码
其他都y(如图!!!是否拒绝自动连接数据库)。
哪我就按n
安装或者下载其他的时候感谢比较慢,可以直接用国内镜像
华为开源镜像站
https://mirrors.huaweicloud.com/
清华大学开源软件镜像站https://mirrors.tuna.tsinghua.edu.cn/
阿里云开源镜像站https://developer.aliyun.com/mirror/
留言评论
暂无留言