mysql_select_db — Selects a database as default

int mysql_select_db(MYSQL * mysql,
                    const char * db);

Sets the current active database on the server that's associated with the specified link identifier. Every subsequent api call will be made on the active database.

Parameters

mysql

A mysql handle, which was previously allocated by mysql_init() or mysql_real_connect().

db

The default database name

Return value

Zero on success, non-zero on failure

[Note]

The SQL command SELECT DATABASE() will return the name of the default database.

The default database can also be set by the db parameter in mysql_real_connect().

See also

mysql_real_connect()