Home > Backend Development > PHP Tutorial > How to Connect to MySQL 4.1 with Old Authentication Using MySQLi?

How to Connect to MySQL 4.1 with Old Authentication Using MySQLi?

Susan Sarandon
Release: 2024-11-07 17:42:03
Original
988 people have browsed it

How to Connect to MySQL 4.1  with Old Authentication Using MySQLi?

Connect to MySQL 4.1 with Old Authentication Using MySQLi

When attempting to establish a connection to a MySQL database with MySQLi, you may encounter the following error:

This error arises due to the use of an outdated password hashing scheme in MySQL versions preceding 4.1. While newer versions allow for the utilization of old passwords, it can lead to the aforementioned issue.

To resolve this problem, follow these steps:

  1. Check Server Settings:

    Execute the SQL query SHOW VARIABLES LIKE 'old_passwords'; to determine if the server defaults to the old password scheme (old_passwords,Off).

  2. Identify Accounts with Old Passwords:

    Use the query SELECT User`, `Host`, Length(`Password`) FROM mysql.user` to list user accounts and their password lengths. Accounts with a password length of 16 use the old scheme, while a length of 41 indicates new passwords.

  3. Change Password for Old Accounts:

    Update the passwords of accounts with old passwords using the statement SET PASSWORD FOR 'User'@'Host'=PASSWORD('yourpassword');. Remember to replace 'User' and 'Host' with the appropriate values from your query.

  4. Flush Privileges:

    Execute FLUSH PRIVILEGES; to apply the changes.

  5. Verify Password Length:

    Re-run the query from Step 2 to confirm that the password lengths are now 41.

By implementing these steps, you should be able to successfully connect to the MySQL database using MySQLi, even though it utilizes the old password scheme.

The above is the detailed content of How to Connect to MySQL 4.1 with Old Authentication Using MySQLi?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template