search
HomeDatabaseMysql TutorialMYSQL版本升级到后5.0后无法连接的有关问题

MYSQL版本升级到后5.0后无法连接的问题 最近使用的机器要迁入机房,但是安全扫描时数据库版本太低了(4.0+)必须升级数据库。于是升级到了 mysql5.6版本,升级完毕,数据迁移完毕后却发现程序怎么也连不上了,对比了密码和配置文件都没有错,后来上网查询才知

MYSQL版本升级到后5.0后无法连接的问题

最近使用的机器要迁入机房,但是安全扫描时数据库版本太低了(4.0+)必须升级数据库。于是升级到了

mysql5.6版本,升级完毕,数据迁移完毕后却发现程序怎么也连不上了,对比了密码和配置文件都没有错,后来上网查询才知道是mysql5.0以后的版本密码加密方式和以前版本不一样,要使用原来的加密方式,必须使用

OLD_PASSWORD函数设置密码。

后面为转载的解决方法,我的解决办法和这个大同小异。

错误MySQL 返回:?
#1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

原因是因为你使用的mysql服务器版本中使用了新的密码验证机制,这需要客户端的版本要在4.0以上,原来的密码函数被改为old_password ();,这样使用password()生成的密码在旧的版本上的客户端就不好使了,而PHP中的MYSQL客户端都是3.23的(当然,mysqli的扩 展除外),问题就在这了。

目前已知解决方法:

1、进入命令行下,转到MYSQL目录的BIN目录下,进入MYSQL命令行模式:
?????????? 例:d:\mysql\bin>mysql -uroot -p123?????????? (用户root,密码123)
2、输入命令:
?????????? mysql>set password for 'root'@'localhost'=old_password('123');?????????? (注意冒号不能少)
3、退入MYSQL命令行:
?????????? mysql>\q

?

A.2.3. 客户端不支持鉴定协议

MySQL 5.1采用了基于密码混编算法的鉴定协议,它与早期客户端(4.1之前)使用的协议不兼容。如果你将服务器升级到4.1之上,用早期的客户端进行连接可能失败,并给出下述消息:

shell>?mysql客户端不支持服务器请求的鉴定协议:请考虑升级MySQL客户端。

要想解决该问题,应使用下述方法之一:

·?????????

·?????????用4.1版之前的客户端连接到服务器时,请使用仍具有4.1版之前风格密码的账户。

·?????????对于需要使用4.1版之前的客户端的每位用户,将密码恢复为4.1版之前的风格。可以使用SET PASSWORD语句和OLD_PASSWORD()函数完成该任务:

·????????????????mysql>?SET PASSWORD FOR·????????????????????????? ->?'some_user'@'some_host' = OLD_PASSWORD('newpwd');

也可以使用UPDATE和FLUSH PRIVILEGES:

mysql>?UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')????????? ->?WHERE Host = 'some_host' AND User = 'some_user';mysql>?FLUSH PRIVILEGES;

用你打算使用的密码替换前例中的“newpwd”。MySQL不能告诉你原来的密码是什么,因此,你需要选择新的密码。

·?????????通知服务器使用旧的密码混编算法:

1.????使用“--old-passwords”选项启动mysqld

2.????对于已将密码更新为较长4.1格式的每个账户,为其指定具有旧格式的密码。可以使用下述查询确定这些账户:

3.?????????????????mysql>?SELECT Host, User, Password FROM mysql.user4.?????????????????????????? ->?WHERE LENGTH(Password) > 16;

对于查询显示的每个账户记录,请使用Host和User值,并使用OLD_PASSWORD()函数以及SET PASSWORD或UPDATE之一指定密码,如前面所介绍的那样。

注释:在早期的PHP版本中,mysql扩展不支持MySQL 4.1.1和更高版中的鉴定协议。无论使用的PHP版本是什么,它均是正确的。如果你打算与MySQL 4.1或更高版本一起使用mysql扩展,需要使用前面介绍的选项之一,配置MySQL,以便与较早的客户端一起使用。mysqli扩展(支持“改进的MySQL”,在PHP 5中增加)与MySQL 4.1和更高版本中使用的改进的密码混编算法兼容,不需要对MySQL进行特殊配置就能使用该MySQL客户端库。关于mysqli扩展的更多信息,请参见http://php.net/mysqli。

?

   首先说明一下,下面描述仅限于Win系统 其它系统我没试过,Mysql 自从4.1.1以后修改了用户密码的格式, 从16位增加到了41位, 采用了一种新的验证方法,但4.1以前的客户端协议不支持这种方法,所以造成了不能登临的后果.即使密码正确了不能正常登录,提示如下:
#1250 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

在窗口中执行:
C:\mysql\bin>mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.0-alpha-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select password('aa');
+-------------------------------------------+
| password('aa')              |
+-------------------------------------------+
| *DEE59C300700AF9B586F9F2A702231C0AC373A13 |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql>
从上可以看出password的结果返回了一个以'*'号开头的41位字符串,而以前是16位的.

Mysql官方网站给出了二种解决方法

1,使用新的客户端api,
2,强制服务器使用旧的密码方案

我首先尝试了第一种方法,从mysql5.0中拷贝libmysql.dll到php 的扩展目录中,替代了php本身附带的libmysql.dll, 但结果令人失望. Php提示装入php_mysql.dll失败:PHP Warning: PHP Startup: Unable to load dynamic library 'c:/php5/ext/php_mysql.dll' - 找不到指定的程序。后来发现新版的dll中缺少了mysql_drop_db() 这一函数 :( 只有等php或mysql出更新的dll了.

第一种方法行不通,只有试试第二种方法,mysql的官方FAQ中说,需要加上-old-password这一参数,我首先尝试 在命令行下起动mysql,
c:\mysql\bin>mysqld-nt -old-password

在另一窗口中 运行
C:\mysql\bin>mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 540 to server version: 5.0.0-alpha-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select password('mypassword');
+------------------------+
| password('mypassword') |
+------------------------+
| 162eebfb6477e5d3    |
+------------------------+
1 row in set (0.55 sec)

mysql>

可以看出password的结果又变成16位的了,可喜的变化

我在c:\windows\my.ini (xp,98,中如此,2000中应在c:\wint\下)中的"mysqld"段中加入"set-variable=old-passwords"

例:
[mysqld]
basedir=C:/mysql
set-variable=old-passwords
datadir=C:/mysql/data
[WinMySQLadmin]
Server=C:/mysql/bin/mysqld-nt.exe
user=root
password=mypassword

然后在服务管理器中起动mysql

Very Good, 一切正常,

后来我又发现,只要在mysql.user表中把password的字段长度改成16系统就自动切换到了oldpassword方式,改成改回41后 又自动换到了新的验证方式.
在这里提醒一下,更改password方式后,要重新设制一下密码并刷新一下权限(或重起mysql)

、先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.
另外看看是不是权限问题.

2、确定你的mysql.sock是不是在那个位置,
mysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock

3、试试:service mysqld start

4、如果是权限问题,则先改变权限 #chown -R mysql:mysql /var/lib/mysql

[root@localhost ~]# /etc/init.d/mysqld start
启动 MySQL: [ 确定 ]
[root@localhost ~]# mysql -uroot -p

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL: An Introduction to the World's Most Popular DatabaseMySQL: An Introduction to the World's Most Popular DatabaseApr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

The Importance of MySQL: Data Storage and ManagementThe Importance of MySQL: Data Storage and ManagementApr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system suitable for data storage, management, query and security. 1. It supports a variety of operating systems and is widely used in Web applications and other fields. 2. Through the client-server architecture and different storage engines, MySQL processes data efficiently. 3. Basic usage includes creating databases and tables, inserting, querying and updating data. 4. Advanced usage involves complex queries and stored procedures. 5. Common errors can be debugged through the EXPLAIN statement. 6. Performance optimization includes the rational use of indexes and optimized query statements.

Why Use MySQL? Benefits and AdvantagesWhy Use MySQL? Benefits and AdvantagesApr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

Describe InnoDB locking mechanisms (shared locks, exclusive locks, intention locks, record locks, gap locks, next-key locks).Describe InnoDB locking mechanisms (shared locks, exclusive locks, intention locks, record locks, gap locks, next-key locks).Apr 12, 2025 am 12:16 AM

InnoDB's lock mechanisms include shared locks, exclusive locks, intention locks, record locks, gap locks and next key locks. 1. Shared lock allows transactions to read data without preventing other transactions from reading. 2. Exclusive lock prevents other transactions from reading and modifying data. 3. Intention lock optimizes lock efficiency. 4. Record lock lock index record. 5. Gap lock locks index recording gap. 6. The next key lock is a combination of record lock and gap lock to ensure data consistency.

What are common causes of poor MySQL query performance?What are common causes of poor MySQL query performance?Apr 12, 2025 am 12:11 AM

The main reasons for poor MySQL query performance include not using indexes, wrong execution plan selection by the query optimizer, unreasonable table design, excessive data volume and lock competition. 1. No index causes slow querying, and adding indexes can significantly improve performance. 2. Use the EXPLAIN command to analyze the query plan and find out the optimizer error. 3. Reconstructing the table structure and optimizing JOIN conditions can improve table design problems. 4. When the data volume is large, partitioning and table division strategies are adopted. 5. In a high concurrency environment, optimizing transactions and locking strategies can reduce lock competition.

When should you use a composite index versus multiple single-column indexes?When should you use a composite index versus multiple single-column indexes?Apr 11, 2025 am 12:06 AM

In database optimization, indexing strategies should be selected according to query requirements: 1. When the query involves multiple columns and the order of conditions is fixed, use composite indexes; 2. When the query involves multiple columns but the order of conditions is not fixed, use multiple single-column indexes. Composite indexes are suitable for optimizing multi-column queries, while single-column indexes are suitable for single-column queries.

How to identify and optimize slow queries in MySQL? (slow query log, performance_schema)How to identify and optimize slow queries in MySQL? (slow query log, performance_schema)Apr 10, 2025 am 09:36 AM

To optimize MySQL slow query, slowquerylog and performance_schema need to be used: 1. Enable slowquerylog and set thresholds to record slow query; 2. Use performance_schema to analyze query execution details, find out performance bottlenecks and optimize.

MySQL and SQL: Essential Skills for DevelopersMySQL and SQL: Essential Skills for DevelopersApr 10, 2025 am 09:30 AM

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.