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).”
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
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.
You can also set the command line to always display warnings after a query using W
You can switch them off again with w
@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.
When MySQL database imports data, warnings often appear.
These warnings are easy to be ignored.
I suddenly want to see what the warnings are when I get to the data today.
MySQL view warning command
The command is very concise, and the general warning is like this when I check it.
Warning | 1265 | Data truncated for column ‘title’ at row 1265
This warning is that the field length is not enough,
the imported data is automatically cropped by the system.
| Warning | 1366 | Incorrect string value: ‘xB5xDAxB6xFExBDxEC...‘ for column ‘Journal title’ at row 1444 |
This is the wrong character set of the data.
For the second one, you need to modify the character set of the database or the txt encoding format of the imported data.
| Warning | 1366 | Incorrect integer value: ‘‘ for column ‘work number’ at row 13 |
This is to insert empty data, if the field allows null values, you can ignore these warnings.
| Warning | 1262 | Row 11 was truncated; it contained more data than there were input columns |
This is a redundant column of imported data.
The MySQL warning is easy to understand, and it is easy to modify the table after the warning message.