170
votes

I just ran a simple MySQL CREATE TABLE statement that produced the line

"Query OK, 0 rows affected, 1 warning (0.07 sec)."

It didn't actually show me what the warning was, though. How can you see the contents of a warning that just occurred? I'm using MySQL 5.1, if it makes a difference. The only thing I found online was "SHOW WARNINGS;" but that only produced

"Empty set (0.00 sec)."

3
as others have pointed out for interactive mysql you can, (1.) start the interactive session with the --show-warnings (see man mysql) or (2.) if you are in an existing interactive session, you can enable the same behavior with warnings (see man mysql).Trevor Boyd Smith

3 Answers

213
votes

SHOW WARNINGS is the only method I'm aware of, but you have to run it immediately after a query that had warnings attached to it. If you ran any other queries in between, or dropped the connection, then SHOW WARNINGS won't work.

The MySQL manual page for SHOW WARNINGS doesn't indicate any other methods, so I'm fairly certain that you're stuck with it.

107
votes

You can also set the command line to always display warnings after a query using \W

You can switch them off again with \w

22
votes

@HorusKol, do you have documentation for that? I couldn't find any. But I did find out that the command line option --show-warnings will do the job, according to the MySQL manual.