11.07.2015 Views

Release Team[oR] 2001 [x] Database - Kataix Umag Cl

Release Team[oR] 2001 [x] Database - Kataix Umag Cl

Release Team[oR] 2001 [x] Database - Kataix Umag Cl

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 4.5 Dropping a database using mysqladmin.You may have noticed that when using mysqladmin, you are prompted before deleting the database.This is very helpful for the beginning database administrator, as well as the seasoned veteran. It allowsone last moment of reflection before all your data is lost.The CREATE and DROP arguments of the mysqladmin utility are not case sensitive, but the name of thedatabase is case sensitive. Another notable point is that you must have the authority to use CREATEand DROP. As root, you have this authority, but if you are not an administrator, you will not be able touse these commands.Adding UsersNow that you have your database up and running, you should give other users the ability to use thedatabase. Today, you will learn how to add users; explaining permissions and user privileges are covered inmore detail on Day 17, "MySQL <strong>Database</strong> Security."To allow a user from your local machine—referred to hereafter as localhost—to gain access to yourdatabase, the user must exist in several places. The MySQL RDBMS contains a database namedmysql. This database holds all the permissions for all MySQL databases. This database consists of thefollowing tables:• User The table that holds all the names, passwords, hosts, and privileges of all theusers of this MySQL RDBMS• db The table that contains all the users, databases, and hostnames for this MySQLRDBMS.• host The table that contains all hostnames, databases, and privileges they hold forthis MySQL RDBMSFor a person to use your database, the hostname of the machine from which he or she will beconnecting must exist in the host table. The user must exist in the user table, and the database mustexist in the db table. Complete the following steps to give another user the ability to use your databasefrom the local machine.1. First, make sure the daemon is running and that you are currently in the mysqldirectory.2. Add the hostname and database to the host table. To do this, you must use theMySQL monitor.3. bin/mysql –p4. Next, you must make the mysql database the active database. To do this, type thefollowing:5. USE mysql;NoteRemember, commands are not case sensitive, but the database objectsare.6. To add the hostname/database combination to this MySQL RDBMS, you must use anSQL INSERT command. Type the following from the command line:7. INSERT INTO mysql VALUES('localhost','sample_db',8. 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');Remember that if you do not type a a \g, the MySQL monitor will continue your statement on thefollowing line. This is helpful because it allows for easily readable commands, and, if you make amistake, you can use the history key to bring it back.Your output should look like that in Figure 4.6.- 36 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!