搜索
首页数据库mysql教程错误 2049 (HY000):使用旧的连接(4.1.1 之前的版本)

测试环境新装了MySQL服务器,在登陆时无法成功登陆。其提示为使用的旧的认证协议而被拒绝。其具体的错误提示为ERROR 2049 (HY000

测试环境新装了MySQL服务器,在登陆时无法成功登陆。其提示为使用的旧的认证协议而被拒绝。其具体的错误提示为ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)以下是关于这个问题的描述及其解决方案,供大家参考。

1、故障现象
[root@HKBO ~]# mysqladmin -u root password 'Mysqlxxx'
[root@HKBO ~]# mysql -uroot -p
Enter password:
ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)

 

2、有关secure_auth参数

  • Command-Line Format --secure-auth

    System Variable Name

    Variable Scope Global

    Dynamic Variable Yes

    Permitted Values (Type boolean

    Default OFF

    Permitted Values (>= 5.6.5) Type boolean

    Default ON

    This option causes the server to block connections by clients that attempt to use accounts that have passwords stored in the old (pre-4.1) format. Use it to prevent all use of passwords employing the old format (and hence insecure communication over the network). Before MySQL 5.6.5, this option is disabled by default. As of MySQL 5.6.5, it is enabled by default; to disable it, use .

    Server startup fails with an error if this option is enabled and the privilege tables are in pre-4.1 format. SeeSection B.5.2.4, “Client does not support authentication protocol”.

    Theclient also has aoption, which prevents connections to a server if the server requires a password in old format for the client account.

    Note

    Passwords that use the pre-4.1 hashing method are less secure than passwords that use the native password hashing method and should be avoided. Pre-4.1 passwords are deprecated and support for them will be removed in a future MySQL release. Consequently, disabling secure authentication usingis also deprecated.

  •  

    3、分析及解决

    #查看当前的配置文件
    [root@HKBO ~]# grep -v ^# /etc/my.cnf
    [mysqld]
    datadir=/opt/data
    socket=/tmp/mysql.sock
    user=mysql
    old_passwords=1 

    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid

    #old_passwords
    #This variable controls the password hashing method used by the PASSWORD() function.
    #It also influences password hashing performed by CREATE USER and GRANT statements that specify a password using an IDENTIFIED BY clause.
    #当值为1的使用正好使用的是Pre-4.1 (“old”) hashing mysql_old_password 旧密码方式,因此先将其禁用

    [root@HKBO ~]# vi /etc/my.cnf

    #如下,禁用后的old_passwords
    [root@HKBO ~]# grep old_passwords /etc/my.cnf
    #old_passwords=1

    #重启mysql
    [root@HKBO ~]# service mysqld stop
    Shutting down MySQL.[  OK  ]

    [root@HKBO ~]# service mysqld start
    Starting MySQL..[  OK  ]

    #登陆还是出现同样的提示
    [root@HKBO ~]# mysql -uroot -p
    Enter password:
    ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)

    #下面尝试使用--secure_auth=off登陆,提示需要改变密码到新格式
    [root@HKBO ~]# mysql -uroot -p --secure_auth=off
    Enter password:
    ERROR 1275 (HY000): Server is running in --secure-auth mode, but 'root'@'localhost' has a password in the old format; please change the password to the new format

    #下面我们增加secure-auth=off到配置文件
    [root@HKBO ~]# grep secure-auth /etc/my.cnf
    secure-auth=off

    #再次重启mysql
    [root@HKBO ~]# service mysqld stop
    Shutting down MySQL.[  OK  ]
    [root@HKBO ~]# service mysqld start
    Starting MySQL.[  OK  ]

    #此时可以透过--secure_auth=off方式登陆
    [root@HKBO ~]# mysql -uroot -p --secure_auth=off
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.6.12 Source distribution

    Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

    Oracle 是 Oracle Corporation 和/或其
    附属公司的注册商标。其他名称可能是其各自
    所有者的商标。

    输入“帮助”;或“h”寻求帮助。输入“c”清除当前输入语句。

    mysql>设置 'root'@'localhost' 的密码 =password('Mysqlxxx');
    查询正常,0 行受影响,1 条警告(0.01 秒)

    mysql>退出
    再见

    #通过上述操作后仍无法登陆,仍需要使用--secure_auth=off方式才能登陆

    #查看威胁的mysql客户端
    [root@HKBO ~]# which mysql
    /app/soft/mysql/bin/mysql

    [root@HKBO ~]# /app/soft/mysql/bin/mysql -uroot -p
    输入密码:
    错误 2049 (HY000): 使用旧的(4.1.1 之前)身份验证进行连接协议被拒绝(启用客户端选项“secure_auth”)

    [root@HKBO ~]# /app/soft/mysql/bin/mysql --version
    /app/soft/mysql/bin/mysql  Ver 14.14 Distrib 5.6.12,适用于 Linux (x86_64),使用 EditLine包装

    [root@HKBO ~]# whereis mysql
    mysql: /usr/bin/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

    #/usr/bin下也有一个mysql客户端,其版本为5.0.95
    [root@HKBO ~]# /usr/bin/mysql --version
    /usr/bin/mysql  Ver 14.12 Distrib 5.0.95,适用于 RedHat-linux-gnu (x86_64),使用 readline 5.1

    #经排查,当前主机有旧版本的mysql
    [root@HKBO mysql]# rpm -qa | grep -i mysql
    mysql-5.0.95-3.el5

    #即将卸载旧版本的mysql
    [root@HKBO ~]# rpm -e --nodeps mysql-5.0.95-3.el5
    警告:/etc/my.cnf 另存为/ etc/my.cnf.rpmsave

    声明
    本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
    减少在Docker中使用MySQL内存的使用减少在Docker中使用MySQL内存的使用Mar 04, 2025 pm 03:52 PM

    本文探讨了Docker中的优化MySQL内存使用量。 它讨论了监视技术(Docker统计,性能架构,外部工具)和配置策略。 其中包括Docker内存限制,交换和cgroups

    mysql无法打开共享库怎么解决mysql无法打开共享库怎么解决Mar 04, 2025 pm 04:01 PM

    本文介绍了MySQL的“无法打开共享库”错误。 该问题源于MySQL无法找到必要的共享库(.SO/.DLL文件)。解决方案涉及通过系统软件包M验证库安装

    如何使用Alter Table语句在MySQL中更改表?如何使用Alter Table语句在MySQL中更改表?Mar 19, 2025 pm 03:51 PM

    本文讨论了使用MySQL的Alter Table语句修改表,包括添加/删除列,重命名表/列以及更改列数据类型。

    在 Linux 中运行 MySQl(有/没有带有 phpmyadmin 的 podman 容器)在 Linux 中运行 MySQl(有/没有带有 phpmyadmin 的 podman 容器)Mar 04, 2025 pm 03:54 PM

    本文比较使用/不使用PhpMyAdmin的Podman容器直接在Linux上安装MySQL。 它详细介绍了每种方法的安装步骤,强调了Podman在孤立,可移植性和可重复性方面的优势,还

    什么是 SQLite?全面概述什么是 SQLite?全面概述Mar 04, 2025 pm 03:55 PM

    本文提供了SQLite的全面概述,SQLite是一个独立的,无服务器的关系数据库。 它详细介绍了SQLite的优势(简单,可移植性,易用性)和缺点(并发限制,可伸缩性挑战)。 c

    在MacOS上运行多个MySQL版本:逐步指南在MacOS上运行多个MySQL版本:逐步指南Mar 04, 2025 pm 03:49 PM

    本指南展示了使用自制在MacOS上安装和管理多个MySQL版本。 它强调使用自制装置隔离安装,以防止冲突。 本文详细详细介绍了安装,起始/停止服务和最佳PRA

    如何为MySQL连接配置SSL/TLS加密?如何为MySQL连接配置SSL/TLS加密?Mar 18, 2025 pm 12:01 PM

    文章讨论了为MySQL配置SSL/TLS加密,包括证书生成和验证。主要问题是使用自签名证书的安全含义。[角色计数:159]

    哪些流行的MySQL GUI工具(例如MySQL Workbench,PhpMyAdmin)是什么?哪些流行的MySQL GUI工具(例如MySQL Workbench,PhpMyAdmin)是什么?Mar 21, 2025 pm 06:28 PM

    文章讨论了流行的MySQL GUI工具,例如MySQL Workbench和PhpMyAdmin,比较了它们对初学者和高级用户的功能和适合性。[159个字符]

    See all articles

    热AI工具

    Undresser.AI Undress

    Undresser.AI Undress

    人工智能驱动的应用程序,用于创建逼真的裸体照片

    AI Clothes Remover

    AI Clothes Remover

    用于从照片中去除衣服的在线人工智能工具。

    Undress AI Tool

    Undress AI Tool

    免费脱衣服图片

    Clothoff.io

    Clothoff.io

    AI脱衣机

    AI Hentai Generator

    AI Hentai Generator

    免费生成ai无尽的。

    热门文章

    R.E.P.O.能量晶体解释及其做什么(黄色晶体)
    2 周前By尊渡假赌尊渡假赌尊渡假赌
    仓库:如何复兴队友
    4 周前By尊渡假赌尊渡假赌尊渡假赌
    Hello Kitty Island冒险:如何获得巨型种子
    3 周前By尊渡假赌尊渡假赌尊渡假赌

    热工具

    WebStorm Mac版

    WebStorm Mac版

    好用的JavaScript开发工具

    SublimeText3 Linux新版

    SublimeText3 Linux新版

    SublimeText3 Linux最新版

    ZendStudio 13.5.1 Mac

    ZendStudio 13.5.1 Mac

    功能强大的PHP集成开发环境

    SublimeText3 Mac版

    SublimeText3 Mac版

    神级代码编辑软件(SublimeText3)

    SublimeText3 英文版

    SublimeText3 英文版

    推荐:为Win版本,支持代码提示!