一.重设密码
1.知道原来的myql的root的密码
方法一:
通过登录mysql系统,mysql -uroot -pEnter password: 【输入原来的密码】mysql>use mysql;mysql> update user set authentication_string=passworD("test123") wher user='root';mysql> flush privileges;mysql> exit;
方法二:
在mysql系统外,使用mysqladminmysqladmin -u root -p password "test123"Enter password: 【输入原来的密码】
2.不知道原来的myql的root的密码
①.跳过密码启动
mysqld_safe --skip-grant-tables &
②.重设密码
# 直接输入mysql,进入mysqlmysqlmysql> use mysql;mysql> UPDATE user SET authentication_string=password("test123") WHERE user='root'; mysql> flush privileges;mysql> exit;
③.重新启动mysql
systemctl restart mysql
二.允许外部访问
1.设置允许访问
# password是数据库密码GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;FLUSH PRIVILEGES;
2.使用navicat检测一下,如果还是不能连接,可能是防火墙限制了。需要在防火墙里面加开放数据库端口的规则。先查看一下目前的防火墙,此时没有放开3306端口!
firewall-cmd --list-all
[root@iZhp3di673f3rx1g5d9dfdZ soft]# firewall-cmd --list-all public target: default icmp-block-inversion: no interfaces: sources: services: dhcpv6-client ssh ports: 20/tcp 21/tcp 22/tcp 80/tcp 8888/tcp 39000-40000/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
3.开放3306端口
firewall-cmd --permanent --add-port=3306/tcp
4.重启防火墙
service firewalld restart
5.查看3306端口是否开放
firewall-cmd --query-port=3306/tcp
[root@iZhp3di673f3rx1g5d9dfdZ soft]# firewall-cmd --query-port=3306/tcpyes
6.再次查看现在防火墙
firewall-cmd --list-all
[root@iZhp3di673f3rx1g5d9dfdZ soft]# firewall-cmd --list-all public target: default icmp-block-inversion: no interfaces: sources: services: dhcpv6-client ssh ports: 20/tcp 21/tcp 22/tcp 80/tcp 8888/tcp 39000-40000/tcp 3306/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
7.此时就可以远程连接了
站在巨人肩膀上摘苹果
https://blog.csdn.net/qq_35070711/article/details/70860014
https://www.cnblogs.com/yybrhr/p/9810375.html
原文转载:http://www.shaoqun.com/a/494800.html
东西网:https://www.ikjzd.com/w/1238
蜜芽宝贝:https://www.ikjzd.com/w/1320
topia:https://www.ikjzd.com/w/2741
一.重设密码1.知道原来的myql的root的密码方法一:通过登录mysql系统,mysql-uroot-pEnterpassword:【输入原来的密码】mysql>usemysql;mysql>updateusersetauthentication_string=passworD("test123")wheruser='root';mysql&g
new old stock:new old stock
拍拍:拍拍
肇庆有哪些旅游景点?:肇庆有哪些旅游景点?
厦门花生汤好吃吗?:厦门花生汤好吃吗?
为什么我的产品老是审核不通过?Lazada产品审核拒绝原因:为什么我的产品老是审核不通过?Lazada产品审核拒绝原因
No comments:
Post a Comment