You may have an Administrator that will create your database for you, but if not, creating a database is a simple process.
Before creating a database, you will want to check through any existing databases in order to confirm that your database does not already exist.
This command will print out an alphabetical list of the databases that you have access to. It might look something like this:
And it might not look something like this, because you have not yet created the "pets" database. Let's do that now.
Note: Database names are case-sensitive!
Now that your database is created, you have to select it for use. How, you might ask? I'm glad you asked!
As soon as you see the message "Database changed", you know you're on the right track!
Alternately, you can skip the "USE database;" step by adding the database name when connecting to MYSQL. Example:
After logging in, if at any time you forget what database you are using, simply type in "SELECT database();" and you will be told.
And now you're all set and ready to go!
Before creating a database, you will want to check through any existing databases in order to confirm that your database does not already exist.
mysql> SHOW DATABASES;
This command will print out an alphabetical list of the databases that you have access to. It might look something like this:
mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
| pets |
| test |
+----------+
And it might not look something like this, because you have not yet created the "pets" database. Let's do that now.
mysql> CREATE DATABASE pets;
Note: Database names are case-sensitive!
Now that your database is created, you have to select it for use. How, you might ask? I'm glad you asked!
mysql> USE pets;
As soon as you see the message "Database changed", you know you're on the right track!
Alternately, you can skip the "USE database;" step by adding the database name when connecting to MYSQL. Example:
mysql> mysql -h host -u username -p pets
After logging in, if at any time you forget what database you are using, simply type in "SELECT database();" and you will be told.
And now you're all set and ready to go!
0 comments:
Post a Comment