MySQL PHP Incompatibility

MySQL PHP incompatibility

The MySQL account you're using probably has an old 16 character long password (hash).

You can test that with a MySQL client (like HeidiSQL, the MySQL console client or any other client) and an account that has access to the mysql.user table. If the Password field contains 16 chars it's an old password and mysqlnd cannot use it to connect to the MySQL server.

You can set a new password for that user with

SET PASSWORD FOR 'username'@'hostmask' = PASSWORD('thepassword')

see dev_mysql_set_password

edit:

You should also check if the server is set to use/create old passwords by default.

edit2:

Please run the query

SELECT
Length(`Password`),
Substring(`Password`, 1, 1)
FROM
`mysql`.`user`
WHERE
`user`='username'

on the 5.0.22 server (the one that's "failing"). Replace username by the account you're using in mysql_connect().

What does that return?

PHP / MySQL character encoding incompatible?

This was apparently caused by differently encoded whitespace.

PHP 7.4 and MySQL Connections

The solution was to simply change the database password to something it can use by logging into mysql in terminal with:

sudo mysql -p -u root

Then running each of these at the mysql> prompt:

ALTER USER 'USERNAME'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'YOUR_PASSWORD';

FLUSH PRIVILEGES;

Since my code is unchanged and still using the same password as before, it should work on both the local PHP 7.4 and the live 5.X. I am not sure how I will do that on the live server, though, as I do not have access to the mysql table.



Related Topics



Leave a reply



Submit