VMware Workstation安装CentOS7,配置java环境,安装mysql,docker,Apache tomcat(三)

CentOs7自带MariaDB数据库,MariaDB是mysql的分支,和mysql基本一样,下面介绍下配置MariaDB

使用命令启动服务
systemctl start mariadb.service
修改root密码
mysqladmin -u root -p password [new password]
后面的 [new password] 是要设置的密码 
回车后出现 Enter password 
输入就密码,如果没有,直接回车
查看mariadb编码
show variables like ‘%col%’
本例 collation_server 字段不是utf8 
修改文件 /etc/my.cnf 
在[mysqld]字段下添加: 
character-set-server = utf8
重新启动mariadb服务
systemctl stop mariadb.service

systemctl start mariadb.service

systemctl enable mariadb ==> 开机自启动

配置端口,开放3306端口,这里把8080,80也一并开放,

firewall-cmd --zone=public --permanent --add-port=3306/tcp

firewall-cmd --zone=public --permanent --add-port=3306/tcp

firewall-cmd --zone=public --permanent --add-port=3306/tcp

端口配置完成后重启防火墙

firewall 常用命令
# 重启
service firewalld restart 
# 开启
service firewalld start 
# 关闭
service firewalld stop
# 查看firewall 服务状态
 systemctl status firewall
# 查看防火墙

 firewall-cmd  --list-all   

防火墙重启后,可以看到端口已经开放


接下来配置使数据库开放对外连接

首先进入数据库,连接方式和mysql一样

mysql -uroot -p

输入你的密码,第一次进入是没有密码的

# 针对ip
create user 'root'@'192.168.10.10' identified by 'password';
#全部
 create user 'root'@'%' identified by 'password';
建议还是针对于ip开放吧,不要全部开放
授权用户:
 # 给用户最大权限
  grant all privileges on *.* to 'root'@'%' identified by '你想设置的密码';
 # 给部分权限(test 数据库)
  grant all privileges on test.* to 'root'@'%' identified by '你想设置的密码' with grant option;
# 刷新权限表
 flush privileges;

# show grants for 'root'@'localhost';
接下来就是可以本地连接了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值