Bug #97748 | Connection errors appear in error.log | ||
---|---|---|---|
Submitted: | 22 Nov 2019 12:23 | Modified: | 26 Nov 2019 12:55 |
Reporter: | Yuri Tkachenko | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connectors: mysqlnd ( PHP ) | Severity: | S3 (Non-critical) |
Version: | 5.7.28 MySQL Community Server | OS: | Any |
Assigned to: | MySQL Verification Team | CPU Architecture: | Any |
[22 Nov 2019 12:23]
Yuri Tkachenko
[25 Nov 2019 15:23]
MySQL Verification Team
Hi Yuri, I'm failing to see how is this MySQL bug? If you look at the error: 454 Connect Access denied for user 'dbuser'@'localhost' (using password: NO) php is trying to connect without password. That's error on the side of the PHP so I assume that's where the bug should be reported.
[26 Nov 2019 12:55]
Yuri Tkachenko
Hello Bigdan, thank you for your reply. Ok, I’ll create a ticket in the PHP bug tracker, I hope we find the truth.
[26 Nov 2019 15:20]
MySQL Verification Team
Hi, please do. I'm not up2date with latest PHP but IIRC doing .. connect(); connect(); .. is not ok. The way php used to handle persistent mysql connections was that when you close, it was not closing it so next time you create a connection it uses the one that already exist. There is ton of reasons why using persistent connections between mysql and php is not a good idea but that's for some other discussion. As you can see in the PHP documentation: [quote] There are a couple of additional caveats to keep in mind when using persistent connections. One is that when using table locking on a persistent connection, if the script for whatever reason cannot release the lock, then subsequent scripts using the same connection will block indefinitely and may require that you either restart the httpd server or the database server. Another is that when using transactions, a transaction block will also carry over to the next script which uses that connection if script execution ends before the transaction block does. In either case, you can use register_shutdown_function() to register a simple cleanup function to unlock your tables or roll back your transactions. Better yet, avoid the problem entirely by not using persistent connections in scripts which use table locks or transactions (you can still use them elsewhere). [/quote] MySQLi extension tries to solve these issues by adding cleanup code but this cleanup code does not execute between your two connect() calls!!! for e.g. if I make this page: <?php $mysqli = new mysqli('p:localhost', 'dbuser', 'QqQqWwWw123!!', 'bugtest'); if ($mysqli->connect_errno) { echo "Errno: " . $mysqli->connect_errno . "\n"; echo "Error: " . $mysqli->connect_error . "\n"; exit; } if (!$result = $mysqli->query('select * from t1')) { echo "Errno: " . $mysqli->errno . "\n"; echo "Error: " . $mysqli->error . "\n"; exit; } while ($row = $result->fetch_assoc()) { echo $row['x'] . ' ' . $row['y'] . "\n"; } $result->free(); $mysqli->close(); ?> and I open this page after the page exits I still see this connection on the mysql server. If I refresh the page I still see the single connection and the data is pulled trough this connection. So, the persistent connection thingy works. So IMO, your PHP code is not properly written but check with PHP ppl I might be in error all best Bogdan