PDA

View Full Version : Setting the active database using mysql C API



guest_user
February 4th, 2011, 12:04 PM
how do I set the active database after logging in:

mysql_real_connect( conn, "localhost", "username", "password", NULL, 0, NULL, 0 );
mysql_query( conn, "create database test" );

after this, now that the database is created, how can I set the active database to be test?

slavik
February 4th, 2011, 12:31 PM
how do I set the active database after logging in:

mysql_real_connect( conn, "localhost", "username", "password", NULL, 0, NULL, 0 );
mysql_query( conn, "create database test" );

after this, now that the database is created, how can I set the active database to be test?
Answer: http://dev.mysql.com/doc/refman/5.0/en/mysql-change-user.html

MadCow108
February 4th, 2011, 01:06 PM
I guess select_db is what op wants:
http://dev.mysql.com/doc/refman/5.0/en/mysql-select-db.html

guest_user
February 4th, 2011, 01:10 PM
I guess select_db is what op wants:
http://dev.mysql.com/doc/refman/5.0/en/mysql-select-db.html

yup but my concern is whether is it deprecated?

slavik
February 4th, 2011, 01:10 PM
I guess select_db is what op wants:
http://dev.mysql.com/doc/refman/5.0/en/mysql-select-db.html
I fail at reading :(

MadCow108
February 4th, 2011, 01:26 PM
yup but my concern is whether is it deprecated?

I see no indication that it is deprecated.

mysql_create_db is deprecated but not mysql_select_db
http://dev.mysql.com/doc/refman/5.5/en/mysql-create-db.html

you can also use mysql_query with a "use test" to select the database

guest_user
February 5th, 2011, 06:14 AM
thank you