tags:

views:

47

answers:

4

Basically I need to connect to the database without any existing databases. In SQL, there was "master" table that still exists. I would need to create the database programatically, therefore I need to connect to the database itself.

A: 

MySQL will always have a mysql database to store user information and other information. There's also the information_schema database in later versions.

Greg
A: 

You can connect to the MySQL server without specifying the database to use.

First execute "CREATE DATABASE db", then "USE db"

True Soft
A: 

Slight confusion here perhaps. You connect to MySQL and it is after you connect to MySQL that you "use" a database.

So the connection would be:

mysql -uusername -ppassword -hhost

This would make the connections regardless of actual databases on the MySQL. Obviously MySQL would need to be there and information_schema in later versions.

After that you would "use database" to use the specific database in that host. As you are connecting programatically etc. I assume after that you will be creating a new database and the the tables/views within that. In that case you might be better off using mysqladmin to create your database remotely first.

PurplePilot
A: 

The mysql and information_schema databases are where the server stores meta information about the database, its permissions, etc. However, you shouldn't modify these databases directly in most cases.

You can do any modification you need to using SQL, but not by editing the control databases. Instead, statements like CREATE DATABASE x and GRANT perm TO user are used to perform administrative functions.

You can connect to MySQL without connecting to any specific database within the server. In that case, any table referenced must be prefixed by their database name, but otherwise everything still works as normal.

tylerl