搜尋
首頁資料庫mysql教程ERROR 2049 (HY000): Connection using old (pre-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 is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    mysql> set password for 'root'@'localhost' =password('Mysqlxxx');
    Query OK, 0 rows affected, 1 warning (0.01 sec)

    mysql> exit
    Bye

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

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

    [root@HKBO ~]# /app/soft/mysql/bin/mysql -uroot -p
    Enter password:
    ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)

    [root@HKBO ~]# /app/soft/mysql/bin/mysql --version
    /app/soft/mysql/bin/mysql  Ver 14.14 Distrib 5.6.12, for Linux (x86_64) using  EditLine wrapper

    [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, for RedHat-linux-gnu (x86_64) using 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
    warning: /etc/my.cnf saved as /etc/my.cnf.rpmsave

    陳述
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
    MySQL的許可與其他數據庫系統相比如何?MySQL的許可與其他數據庫系統相比如何?Apr 25, 2025 am 12:26 AM

    MySQL使用的是GPL許可證。 1)GPL許可證允許自由使用、修改和分發MySQL,但修改後的分發需遵循GPL。 2)商業許可證可避免公開修改,適合需要保密的商業應用。

    您什麼時候選擇InnoDB而不是Myisam,反之亦然?您什麼時候選擇InnoDB而不是Myisam,反之亦然?Apr 25, 2025 am 12:22 AM

    選擇InnoDB而不是MyISAM的情況包括:1)需要事務支持,2)高並發環境,3)需要高數據一致性;反之,選擇MyISAM的情況包括:1)主要是讀操作,2)不需要事務支持。 InnoDB適合需要高數據一致性和事務處理的應用,如電商平台,而MyISAM適合讀密集型且無需事務的應用,如博客系統。

    在MySQL中解釋外鍵的目的。在MySQL中解釋外鍵的目的。Apr 25, 2025 am 12:17 AM

    在MySQL中,外鍵的作用是建立表與表之間的關係,確保數據的一致性和完整性。外鍵通過引用完整性檢查和級聯操作維護數據的有效性,使用時需注意性能優化和避免常見錯誤。

    MySQL中有哪些不同類型的索引?MySQL中有哪些不同類型的索引?Apr 25, 2025 am 12:12 AM

    MySQL中有四種主要的索引類型:B-Tree索引、哈希索引、全文索引和空間索引。 1.B-Tree索引適用於範圍查詢、排序和分組,適合在employees表的name列上創建。 2.哈希索引適用於等值查詢,適合在MEMORY存儲引擎的hash_table表的id列上創建。 3.全文索引用於文本搜索,適合在articles表的content列上創建。 4.空間索引用於地理空間查詢,適合在locations表的geom列上創建。

    您如何在MySQL中創建索引?您如何在MySQL中創建索引?Apr 25, 2025 am 12:06 AM

    toCreateAnIndexinMysql,usethecReateIndexStatement.1)forasingLecolumn,使用“ createIndexIdx_lastNameEnemployees(lastName); 2)foracompositeIndex,使用“ createIndexIndexIndexIndexIndexDx_nameOmplayees(lastName,firstName,firstName);” 3)forauniqe instex,creationexexexexex,

    MySQL與Sqlite有何不同?MySQL與Sqlite有何不同?Apr 24, 2025 am 12:12 AM

    MySQL和SQLite的主要區別在於設計理念和使用場景:1.MySQL適用於大型應用和企業級解決方案,支持高性能和高並發;2.SQLite適合移動應用和桌面軟件,輕量級且易於嵌入。

    MySQL中的索引是什麼?它們如何提高性能?MySQL中的索引是什麼?它們如何提高性能?Apr 24, 2025 am 12:09 AM

    MySQL中的索引是數據庫表中一列或多列的有序結構,用於加速數據檢索。 1)索引通過減少掃描數據量提升查詢速度。 2)B-Tree索引利用平衡樹結構,適合範圍查詢和排序。 3)創建索引使用CREATEINDEX語句,如CREATEINDEXidx_customer_idONorders(customer_id)。 4)複合索引可優化多列查詢,如CREATEINDEXidx_customer_orderONorders(customer_id,order_date)。 5)使用EXPLAIN分析查詢計劃,避

    說明如何使用MySQL中的交易來確保數據一致性。說明如何使用MySQL中的交易來確保數據一致性。Apr 24, 2025 am 12:09 AM

    在MySQL中使用事務可以確保數據一致性。 1)通過STARTTRANSACTION開始事務,執行SQL操作後用COMMIT提交或ROLLBACK回滾。 2)使用SAVEPOINT可以設置保存點,允許部分回滾。 3)性能優化建議包括縮短事務時間、避免大規模查詢和合理使用隔離級別。

    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脫衣器

    Video Face Swap

    Video Face Swap

    使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

    熱工具

    SAP NetWeaver Server Adapter for Eclipse

    SAP NetWeaver Server Adapter for Eclipse

    將Eclipse與SAP NetWeaver應用伺服器整合。

    DVWA

    DVWA

    Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

    SublimeText3 Mac版

    SublimeText3 Mac版

    神級程式碼編輯軟體(SublimeText3)

    記事本++7.3.1

    記事本++7.3.1

    好用且免費的程式碼編輯器

    VSCode Windows 64位元 下載

    VSCode Windows 64位元 下載

    微軟推出的免費、功能強大的一款IDE編輯器