I\'m running WAMP locally, but connecting to a remote MySQL database. The local version of PHP is the latest 5.3.0.
One of the remote databases, being version 5.0.45
My webhost has different versions of PHP/MySQL configured and to use a certain one I need to use the correct .php extension - notably .php5 It might be something as simple as that.
I have been trying to find a simple fix for this problem. Try this approach. In MySQL type
SELECT Host, User, Password FROM mysql.user;
If your password is sixteen characters, this is because you have used OLD_PASSWORD on your user's or have been running an old version of MySQL. To update type in
UPDATE mysql.user SET Password=PASSWORD('newpass')
WHERE User='root' AND Host='localhost';
FLUSH PRIVILEGES;
swapping root, localhost and newpass for your user, host and pass respectively. Now when you re-type
SELECT Host, User, Password FROM mysql.user;
Your password should have changed. This fixed it for me.
After lots of search and tries I found a way without needage to any downgrade/upgrade of MySQL and any affect on other users of running instance of MySQL.
The solution is to resetting password by:
for MySQL versions newer than 5.7.5 ( > 5.7.5):
ALTER USER 'mysqlUsername'@'hostname' IDENTIFIED WITH mysql_native_password BY 'mysqlUsernamePassword';
for older versions of MySQL: ( <= 5.7.5)
SET PASSWORD FOR 'mysqlUsername'@'hostname' = PASSWORD('mysqlUsernamePassword');
I found the point here!
It made mine working well!
Reverting to PHP 5.2.* did the trick! THANK YOU!
If you're using WAMP... left click wamp > php > version> get more>
select the version you want and download.
install/run the exe
left click wamp > php > version> PHP 5.2.*
That fixed this issue. I couldn't run any of these SQL commands without getting a "command denied to user 'XXX'@'localhost'" error. Good look trying to log on as SU 'Root'. Maybe on a personal server, but not going to happen on a real host.
As the user Evernoob above said:
"Reverting to PHP 5.2.* i.e. anything lower than 5.3.0 resolves the problem completely. As long as I am not running 5.3.0 I can connect to both databases. I'm not sure what the explanation is for this weirdness"
In the case of connecting to a shared hose (in our case DreamHost), who is using the oldpassword option, we could not modify the users table. These suggested options will work in other scenarios, just not with shared web hosting.
Of note, we are running WAMP.
A more simple solution is to delete the database user and create a new one with the same username and password.