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
Laravel Catch Tokenmismatchexception
How to Pass an Array via $_Get in PHP
Access Denied for User 'Root'@'Localhost' with PHPmyadmin
Will a Script Continue to Run Even After Closing a Page
Can You Append Strings to Variables in PHP
What Is the Max Key Size for an Array in PHP
How to Get Common Values from Two Different Arrays in PHP
How to Pass Data Between Pages in PHP
How to Implement Content-Disposition: Attachment
Pdo + MySQL and Broken Utf-8 Encoding
PHP Built in Server and .Htaccess Mod Rewrites
Call to Undefined Function Apache_Request_Headers()
Nginx Redirect Loop, Remove Index.PHP from Url
Get Most Recent Date from an Array of Dates in "Y-M-D H:I:S" Format
How to Make Strpos Case Insensitive