How do I view MySQL query errors and warnings in RDS? I am still using MySQL 5.6.
I have looked in the log files (under Log & Events), but they remain empty even when I do a query that generates an error in the console. For example, I ran a query that gave me error 1054 (unknown column), but nothing appeared in the error log. I've realized that this isn't the type of errors that get logged.
The log_warnings parameter is set to 1. I've tried setting general_log=1, but that generates way to much info, and still doesn't log the errors.
The reason that I need this is that I am upgrading from 5.6 to 5.7. I need like to see what warnings I'm currently getting since some warning will become errors in 5.7, and need to be fixed.
You can run SHOW WARNINGS immediately after the query, to get all conditions (errors, warnings, and notes). You have to do this in the client that ran the query. It's not a log.
There is no log for error, warnings, or notes for each query. The errors and warnings in the MySQL Server error log are for server errors, not for individual queries.
Queries that can't be parsed are not written to the general log or the slow query log by default. If you set the global option log_raw=1 then the general log will log erroneous queries, but still won't log the error itself. Even with that option, the slow query log won't log queries that can't be parsed.
A free tool from Percona may be helpful for your testing. pt-upgrade allows you to use a query log file as input, and it runs the query against two instances of MySQL, and reports any difference in errors or warnings, or results.
I thought of another partial solution: the PERFORMANCE_SCHEMA has tables for statement events. The statement event tables have columns for error number and message caused by each query, if any. But only a count of the warnings, not the warning message(s) themselves.
Related
I'm using Azure Database for MySql Server, and when running a certain stored procedure, I get this error:
In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'mydatabase.mytable.id'; this is incompatible with sql_mode=only_full_group_by
Now I know why I'm getting it, and I will fix the query, but it's a pretty massive query, and will take some time to do so. For now, as a temporary solution to get my clients working again, I'd like to set only_full_group_by to false. I understand that to set this globally, I need superuser priviledges, so I logged into Azure Portal, went to "Azure Database for MySQL server", went to "Server Parameters" looked for the "sql_mode" parameter, and was going to turn the "only_full_group_by" option off, but I saw it was already off. So I'm not sure why I am still getting the error.
I then tried turning it off for the session:
set session sql_mode='';
but I am STILL getting that error.
Is there no way to turn "only_full_group_by" off in Azure Database for MySql Server?
Thanks
I just upgraded MySQL from 5.1 to 5.5.
I fixed few issues running mysql_upgrade, and changing some deprecated configurations...
I also updated PHP, from 5.3.3-7 to 5.3.29-1.
But, since that, I'm having a reccurent problem (always thrown in this order) :
1. Client* - PHP Warning
Warning: Packets out of order. Expected 1 received 0. Packet size=1 in
/home/www/www.mywebsite.com/shared/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php
line 694
2. Client* - PHP Warning
Warning: PDOStatement::execute() [pdostatement.execute]: Error reading
result set's header in
/home/www/www.mywebsite.com/shared/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php
line 694
3. Server* - MySQL Warning :
150127 17:25:15 [Warning] Aborted connection 309 to db:
'my_database' user: 'root' host: '127.0.0.1' (Got an error
reading communication packets)
4. Client* - PHP Error
PDOStatement::execute() [pdostatement.execute]: MySQL server
has gone away in
/home/www/www.mywebsite.com/shared/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php
line 694
*NB: What I call "Client" is the PHP Application, and "Server" is the MySQL Server, even if they're both on the same localhost Server.
So, apparently, the origin of all those problems is the first one : "Packets out of order".
But when I search for this error I can't find many answers, and they are most of the time not related to my problem : I use Doctrine as an abstraction, so I don't write any query or fetch any result myself. Plus, it's almost never the same values as me, but in my case I always get those values ("Expected 1 received 0. Packet size=1").
The closest result would be this MySQL bug report, but "No feedback was provided for this bug for over a month, so it is
being suspended automatically"...
Plus, some of the "2." errors aren't thrown by my PHP Doctrine code (they're not executed from my localhost, but from another known external service, probably using some old PHP Propel code).
So that might mean there is a problem with my MySQL configuration itself, but I tried changing some parameters without obtaining any obvious effect (sometimes it takes more time after restarting MySQL to get the first errors for example).
Any help would be very much appreciated !
And here is my current configuration (I've got 2 MySQL instances, the second one using replication is mostly for read only).
I also checked most of the system resources with Munin and didn't see anything abnormal (the RAM usage for example is pretty high, but as there is 50Go on the server it's not full at all).
UPDATE
I isolated an SQL query that was repeatedly failing from my PHP Client. When I executed from my local with MySQL Workbench, it did exactly the same (closed the connexion with a MySQL server has gone away message). When I did it from the sql command line it also did the same. Then I executed it from the sql command line on the server host, and it succeded. But some time after when I tried again from Workbench/whatever it worked... So it looks like those "corrupted packets" are cached and disapear after some time.
Thanks, I fixed this issue doing :
RESET QUERY CACHE;
FLUSH QUERY CACHE;
It is a purely MySQL tweaking question on logging the failed SQL attempts.
I need a solution to log the failed SQLs on the MySQL database.
The MySQL general query log does not work here, because it will log only the successful queries only. I need to know the failed ones in a different log file.
My scenario is: I need to cleanup a big messy SQLs and PHP Scripts (literally, around 7,000 SQLs being executed per page). Since the errors are suppressed on the server, even the SQLs failed queries will continue and show the good contents on the website. But I am sure, there are a lot of SQL errors. I found 2 links but cannot retry. This one and writing server side audit plugin in MySQL.
Is using Kontrolbase an answer as mentioned here.
Percona Server 5.5.37 and 5.6.17 include an implementation of an audit plugin which is free and open-source. Read about it here: http://www.percona.com/doc/percona-server/5.6/management/audit_log_plugin.html
The audit plugin logs both successful queries and erroneous queries. Here's an example where I queried my table foo and then a non-existent table foobar:
<AUDIT_RECORD
"NAME"="Query"
"RECORD"="489_2014-05-23T14:06:09"
"TIMESTAMP"="2014-05-23T14:08:13 UTC"
"COMMAND_CLASS"="select"
"CONNECTION_ID"="32709"
"STATUS"="0"
"SQLTEXT"="select * from foo"
"USER"="root[root] # localhost []"
"HOST"="localhost"
"OS_USER"=""
"IP"=""
/>
<AUDIT_RECORD
"NAME"="Query"
"RECORD"="490_2014-05-23T14:06:09"
"TIMESTAMP"="2014-05-23T14:08:19 UTC"
"COMMAND_CLASS"="select"
"CONNECTION_ID"="32709"
"STATUS"="1146"
"SQLTEXT"="select * from foobar"
"USER"="root[root] # localhost []"
"HOST"="localhost"
"OS_USER"=""
"IP"=""
/>
STATUS=1146 is indicated for the error query above. See http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html to reference server errors. For example, 1146 is ER_NO_SUCH_TABLE.
If you can't use this solution, then you'll have to change your PHP code to remove the error suppression, and log the errors.
I need to capture all of the query errors that are happening on my MySQL server. I've looked into the general_log and that appears to just save the queries, but NOT the result (whether there was an error thrown or not). I've heard some people say the server can't do this, and it can only be done on the client. This seems like a common function, so I would be surprised if there was no option to log query errors on the server.
How can I log these query errors?
There is no error.log in MySQL like you desire, see here what you can log with MySQL.
The only way is to look in your own error.logs e.g. in php:
catch the mysql_error or mysqli_error in php and write your own log-file
or
look in your apache-error-log when you didnĀ“t catch your errors
I have an issue where our database is receiving ~1000 updates a minute, and often we get an error response:
TAF: 1297 (HY000) at line 1: Got temporary error 899 'Rowid already allocated' from NDBCLUSTER
which appears in our application to our customer.
Is there any way to suppress these errors at the MySQL level? As I am not the developer of this application, I am not sure what language is performing the updates, but I presume either shell script or a C program.
I am using MySQL: 5.1.44-ndb-7.1.3-cluster-log (2 cluster nodes and 1 cluster mgmt node)
Have you tried using the 'IGNORE' clause in your SQL statements, the documentation for this is here
Using the IGNORE clause will downgrade errors to warnings, these warnings are displayed using the 'SHOW WARNINGS;' command