The world's most popular open source database
If the administrator creates your database for you when setting up your permissions, you can begin using it. Otherwise, you need to create it yourself:
mysql> CREATE DATABASE menagerie;
Under Unix, database names are case sensitive (unlike SQL
keywords), so you must always refer to your database as
menagerie, not as
Menagerie, MENAGERIE, or
some other variant. This is also true for table names. (Under
Windows, this restriction does not apply, although you must
refer to databases and tables using the same lettercase
throughout a given query. However, for a variety of reasons, our
recommended best practice is always to use the same lettercase
that was used when the database was created.)
If you get an error such as ERROR 1044 (42000): Access denied for user 'monty'@'localhost' to database 'menagerie' when attempting to create a database, this means that your user account does not have the necessary privileges to do so. Discuss this with the administrator or see Section 5.5, “The MySQL Access Privilege System”.
Creating a database does not select it for use; you must do that
explicitly. To make menagerie the current
database, use this command:
mysql> USE menagerie
Database changed
Your database needs to be created only once, but you must select
it for use each time you begin a mysql
session. You can do this by issuing a
USE statement as shown in the
example. Alternatively, you can select the database on the
command line when you invoke mysql. Just
specify its name after any connection parameters that you might
need to provide. For example:
shell>mysql -hEnter password:host-uuser-p menagerie********
Note that menagerie in the command just shown
is not your password. If you
want to supply your password on the command line after the
-p option, you must do so with no intervening
space (for example, as -pmypassword, not as
-p mypassword). However, putting your
password on the command line is not recommended, because doing
so exposes it to snooping by other users logged in on your
machine.


User Comments
You can use this command to view the current database that you're connected to:
mysql> select database();
As it would seem that many users will be anxious to get through the tutorial without branching off to the Administrators guide and learning all of that right now, it would be helpful to explain how the user can Create Database Menagerie without getting a permissions error.
On a Mac, I logged in as Root, and then in Terminal, started MySQL. Once in MySQL, I issued the command 'Grant All On *.* to mynormallogonname@localhost;' and all was good from there for me to create the database.
(It also seems necessary to log in as Root to make use of the MySQL Administrator program if you want to save changes there.)
I've just started using MySQL and am stuck at the 1044 error message. I agree with the previous poster, I think it would be good to include a quick fix here. I've spent over three and a half hours reading the links and doing some googling and can't figure out how to create a username and password to get beyond this step.
You need to check with your server host to get the correct information.
- hostname : this will be the IP number of your domain, such as 127.0.0.1
- username : you need to first create a database, then set the user(s) for the database before you can establish any user names. usernames can be the first seven letters of your domain + a number _ with the database name as a suffix.
For example, www.mywebsite.com would be mywebsi4_profiles.
"mywebsi4_profiles" is the username.
- password : when you create the user(s) of the database, you set the password for each user. mysql will prompt you for the password once the connection to the server is made with the correct hostname and username.
Add your own comment.