You can use the perror command to look up MySQL error codes on the operating system command line:
UNIX > mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13609
Server version: 5.5.19 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select * from andrew;
ERROR 1046 (3D000): No database selected
mysql> exit
Bye
UNIX > perror 1046
MySQL error code 1046 (ER_NO_DB_ERROR): No database selected
UNIX >