What is the HY number (HY000) in MySQL Error messages? When I get an error some of them have an HY code,


  ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")


What is HY000 in the above context. See this question for another example of HY000 in an error message
MySQL reports with ODBC error numbers which include a SQLSTATE. HY000 is a MySQL ODBC extension for there being no ODBC equivalent error number from the docs on Server Error Codes and Messages


  A five-character SQLSTATE value ('42S02'). The values are taken from ANSI SQL and ODBC and are more standardized. Not all MySQL error numbers have corresponding SQLSTATE values. In these cases, 'HY000' (general error) is used.


You can find the HY000 Error Codes in error_code.h, and the full list of authoritative ODBC error codes from the Microsoft ODBC Appendix

The 2 "No such file or directory" is operating system specific.