linux 开放mysql端口

问题

在配置mysql后,需要放开3306端口,出现了FirewallD is not running错误

[root@hadoop102 mysql]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
FirewallD is not running

1.启动firewalld

systemctl start firewalld

2.查看firewalld

systemctl status firewalld

3.重新开放端口

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

4.查看已开启的端口

firewall-cmd --list-ports

报错

开放之后,telnet连接还是提示

FHost '192.168.190.1' is not allowed to connect to this MySQL server

解释:

这个错误表示客户端尝试连接到MySQL服务器时,服务器检查到客户端的IP地址没有被授权访问权限。MySQL的用户权限是基于用户名和来源IP的组合来判断的。

解决办法:

1.在MySQL所在服务器上使用命令登录到MySQL数据库中

   mysql -u root -p

2.选择mysql数据库,并查询权限



3.查看权限

select host from user where user='root';

4.修改 (前后)

update user set host = '%' where user ='root';

5.刷新

flush privileges;

二.发现还是出现问题 (切记在切换验证插件的时候,重新修改一下密码)

 错误原因是加密方式的问题

    MySql 8.0.11 换了新的身份验证插件(caching_sha2_password),

    而原来的身份验证插件为(mysql_native_password)。

只需要更改一下加密方式即可解决

首先执行如下SQL语句进入mysql数据库

mysql>use mysql;

执行如下SQL语句查看加密方式

mysql>select user, plugin from user where user= 'root';

看到加密方式为caching_sha2_password。

执行如下SQL语句更改加密方式

mysql>alter user "root"@"%"  identified with mysql_native_password by "(your password)";

把(your password)替换成你的密码

再次执行

mysql>select user, plugin from user where user= 'root';

看到加密方式已经改变

三.心态崩了,继续干。

1045-Access denied for user root@192.168.194.1(using password:YES)解决方案

(切记在切换验证插件的时候,重新修改一下密码)刚才因为退出mysql没有修改密码,导致密码错误

3.1) 跳过MySQL密码验证

vi /etc/my.cnf

在第一行加入   skip-grant-tables

3.2)若MySQL已经启动,重启MySQL服务器

systemctl restart mysqld

3.3)将登录密码设置为空,然后退出 exit

update user set authentication_string='' where user='root';

3.4) 1.重新登录,2.刷新权限,3.重置密码

    1.mysql -uroot -p  两次回车

    2. flush privileges;

    3. ALTER USER 'root'@'%' IDENTIFIED BY '新密码';

3.5)将跳过权限去掉

vi /etc/my.cnf

在第一行加入   skip-grant-tables  注释掉

成功连接

参考地址:ERROR 1045 (28000) Access denied for user ‘root‘@‘localhost‘ (using password YES/NO)_error 1045 (28000): access denied for user 'root'@-CSDN博客

相关推荐

  1. Linux防火墙开放端口

    2024-06-08 15:00:04       37 阅读
  2. Linux 服务器内开放指定的端口

    2024-06-08 15:00:04       41 阅读
  3. Linux Centos7.5 开放指定端口

    2024-06-08 15:00:04       5 阅读
  4. ubuntu开放防火墙端口

    2024-06-08 15:00:04       34 阅读
  5. linux端口转发

    2024-06-08 15:00:04       33 阅读
  6. 查看mysql数据库端口

    2024-06-08 15:00:04       7 阅读
  7. centos firewalld开放某个端口

    2024-06-08 15:00:04       15 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-08 15:00:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-08 15:00:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-08 15:00:04       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-08 15:00:04       20 阅读

热门阅读

  1. 自然语言处理(NLP)技术。

    2024-06-08 15:00:04       11 阅读
  2. MacOS - Mac 电脑启动台找不到 VSCode 解决方案

    2024-06-08 15:00:04       8 阅读
  3. php设计模式之单例模式详解

    2024-06-08 15:00:04       7 阅读
  4. Tomcat 启动闪退问题解决方法

    2024-06-08 15:00:04       7 阅读
  5. python创建项目时关于new conda environment的解释

    2024-06-08 15:00:04       10 阅读
  6. 汽车线束搭铁与接地

    2024-06-08 15:00:04       7 阅读
  7. [React]useEffect中return函数执行时机

    2024-06-08 15:00:04       10 阅读
  8. 【Spark】直接从DataFrame的schema创建表

    2024-06-08 15:00:04       10 阅读
  9. 软件造价评估常用术语与缩略语解析

    2024-06-08 15:00:04       8 阅读
  10. object oriented programming CS32

    2024-06-08 15:00:04       9 阅读
  11. TP8 PHP 动态变量调用 (new $class())->$action($data)

    2024-06-08 15:00:04       7 阅读