You can call the mysql_list_dbs() function to return a result set consisting of database names that match the simple regular expression specified by the wild argument.
Syntax
MYSQL_RES *
mysql_list_dbs(MYSQL *mysql,
const char *wild)
wild may contain the wildcard character % or _, or may be a NULL pointer to match all databases.
Return values
A MYSQL_RES result set is returned for an execution success, and NULL is returned if an error occurred.
Errors
CR_COMMANDS_OUT_OF_SYNC: Commands were executed in an improper order.CR_OUT_OF_MEMORY: The memory is insufficient.CR_SERVER_GONE_ERROR: The connection to the OBServer was disconnected.CR_SERVER_LOST: The connection to the server was lost during the query.CR_UNKNOWN_ERROR: An unknown error occurred.
Notes
Calling mysql_list_dbs() is similar to executing the query SHOW DATABASES [LIKE wild]. After the call is completed, you must free the result set with mysql_free_result().