BigBill Posted October 21, 2010 Share Posted October 21, 2010 Hello, I have a very frustrating problem. I have some php code that needs to connect to a MySQL database on another server. The connection needs to be through SSL. When I go to connect I get this error message: Connect Error (1045) Access denied for user 'WebUser'@'mydomain.com' (using password: YES) I have checked that I can log in with WebUser using another client program. I am worried that PHP is not finding my SSL certificates. For testing purposes I am running the PHP server from my windows machine, and have the path for the certificates as "C:\temp\client-key.pem" etc. Does anyone else think this is the problem? Quote Link to comment https://forums.phpfreaks.com/topic/216464-mysql-connect-error-1045-access-denied-with-ssl/ Share on other sites More sharing options...
BigBill Posted October 22, 2010 Author Share Posted October 22, 2010 OK, I have found that it isn't the location of the SSL certificates. When I change the path to something that doesn't exist I get an error saying "SSL certificate error", so that rules that out. But I am still having no luck. In desperation, I uploaded the code to my web server and tried it out there. Now things are even more confusing. When I try to run the page it just hangs and doesn't open at all - not even if I leave it for 15 minutes. Here is the code: define ("HOST","mydomain.com"); define ("USER","WebUser"); define ("PASSWORD","password"); define ("DATABASE","Database"); echo phpinfo(); $mysqli = mysqli_init(); if (!$mysqli) { die('mysqli_init failed'); } $mysqli->ssl_set('/etc/ssl/client-key.pem','/etc/ssla/client-cert.pem', '/etc/ssla/ca-cert.pem',NULL,NULL); if (!$mysqli->options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0')) { die('Setting MYSQLI_INIT_COMMAND failed'); } if (!$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5)) { die('Setting MYSQLI_OPT_CONNECT_TIMEOUT failed'); } if (!$mysqli->real_connect(HOST, USER, PASSWORD, DATABASE, NULL, NULL, MYSQLI_CLIENT_SSL)) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } If I remove the MYSQLI_CLIENT_SSL flag I get the error message "Connect Error (1045) Access denied". If I put the flag in the page just hangs and never loads. What could be wrong? I mean, this code was copied and pasted straight out of the PHP documentation! Quote Link to comment https://forums.phpfreaks.com/topic/216464-mysql-connect-error-1045-access-denied-with-ssl/#findComment-1125060 Share on other sites More sharing options...
fenway Posted October 23, 2010 Share Posted October 23, 2010 Might be a firewall/port issue. Quote Link to comment https://forums.phpfreaks.com/topic/216464-mysql-connect-error-1045-access-denied-with-ssl/#findComment-1125633 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.