I'm trying to connect with MySQL in a command line php script file. I have another file which I'm running in GUI Mode, but in Command Line mode it is giving me below error at the time of mysqli_connect:
mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file
I understand that I can update my password. But due to some reason, I can't update the old password with the new Passwords. So I just need to connect with the mysql with the support of old password.
Again, I am mentioning the same code is working fine in GUI mode but not in CLI mode on the same server. How it is happening. Anyone has any idea?
Can you check which PHP.ini files is used by Web Server and Command Line PHP? For web server, just create a page with phpinfo() and check location of php.ini file. Once you get the PHP.ini file location used by Web Server, then you can execute your PHP script from command line using
php -c <Path of PHP.ini> <Your PHP Script>