Name

mysql_create_db( )

Synopsis

int mysql_create_db(MYSQL *mysql, const char *database)

Use this to create a new database on the MySQL server. The new database’s name is given as the second argument. This function has been deprecated. Instead, a CREATE DATABASE statement should be given with mysql_query( ) or mysql_real_query().

...
mysql_real_connect(mysql,host,user,password,NULL,0,NULL,0);
mysql_create_db(mysql, "new_database");
mysql_select_db(mysql, "new_database");
...

This program excerpt creates a database named new_database. The parameters for the mysql_real_connect( ) function are variables declared earlier in the program. Notice that the fifth argument (the parameter for the initial database to use) is set to NULL.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.