Creating And Selecting A Database - Oracle 5.0 Reference Manual

Table of Contents

Advertisement

| Database |
+----------+
| mysql
| test
| tmp
+----------+
The
mysql
workspace for users to try things out.
The list of databases displayed by the statement may be different on your machine;
does not show databases that you have no privileges for if you do not have the
privilege. See
If the
test
mysql>
USE test
Database changed
USE, like QUIT, does not require a semicolon. (You can terminate such statements with a semicolon
if you like; it does no harm.) The
single line.
You can use the
create in that database can be removed by anyone else with access to it. For this reason, you should
probably ask your MySQL administrator for permission to use a database of your own. Suppose that
you want to call yours menagerie. The administrator needs to execute a command like this:
mysql>
GRANT ALL ON menagerie.* TO 'your_mysql_name'@'your_client_host';
where
your_mysql_name
host from which you connect to the server.

3.3.1. Creating and Selecting a 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, the recommended best practice is always to use the same lettercase that was used when the
database was created.)
Creating a database does not select it for use; you must do that explicitly. To make
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
session. You can do this by issuing a
mysql

Creating and Selecting a Database

|
|
|
database describes user access privileges. The
Section 13.7.5.11,
"SHOW DATABASES
database exists, try to access it:
USE
database (if you have access to it) for the examples that follow, but anything you
test
is the MySQL user name assigned to you and
Note
If you get an error such as
for user 'monty'@'localhost' to database 'menagerie'
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 6.2, "The MySQL Access Privilege
Syntax".
statement is special in another way, too: it must be given on a
ERROR 1044 (42000): Access denied
statement as shown in the example. Alternatively,
USE
198
database often is available as a
test
SHOW DATABASES
your_client_host
System".
SHOW DATABASES
is the
when
the
menagerie

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents