I am facing a peculiar problem. I am able to connect to a remote mysql server using ssl with a php script run via ./yii console command. However, the same thing doesnt work when I try to access it via php yii serve (I get following error : yii\base\ErrorException: mysqli_real_connect(): (HY000/1045): Access denied for user ‘user’@‘IP ADDR’ (using password: YES). Can someone help me understand what could be the issue here? I have verified the phpinfo() is same in both the cases and it is exactly the same.
I have cross checked them multiple times and they are same at both the places. Moreover, I copy pasted the same thing. I am not picking the credentials from any config file, I am providing them in the constructor of mysqli_real_connect() itself.
Actually I am trying to connect to a remote Mysql server which requires SSL. Yii’s PDO is not working for me for some reason so I was trying to use other inbuilt functions (mysqli_real_connect). If mysqli is not being used by Yii, then how can this be rectified? Is there a better way to make this whole thing work?
I have an application specific DB, which I am connecting to using PDO (it is fine). Then there is this remote Mysql server, which I am not able to connect using PDO because of SSL peer match issue. I have tried this resolve by doing PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => False , but the constant is not present in the PDO. However, if I do **`php -r ‘var_dump(PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT);’, i get int(1014) as the output.
Not sure why my appilcation is not picking the constant.
PHP version 7.1.28 and Yii2.
Any help would be highly appreciated.