HP OSMS Blueprint: Database Server on HP ProLiant Servers with MySQL and SLES10
NOTE: If you have a large amount of data, shutting down the database might take several
minutes.
# /etc/init.d/mysql stop
# ps –ef | grep mysqld
Creating and Deleting the MySQL Database
In this section, you create a database, delete a database, and add a table.
1. Use the mysqladmin command to create a database. For this example, create a database
named osmsdb by entering the following command:
# mysqladmin –u root –p create osmsdb
2. At the prompt, enter the MySQL root password.
3. Start the MySQL client by entering the following command:
# mysql –u root –p osmsdb
4. Create a sample table by entering the following:
mysql> create table sample (
id int(10) auto_increment not null primary key,
name char(20),
index(id)
);
This creates a new table named sample with two columns, one called id of type integer
and the other called name of type string. The table is indexed by the id column, which is
also the table's primary key.
5. If the table is created without any errors, the following is displayed:
Query OK, 0 rows affected (0.04 sec)
For a detailed explanation of the SQL commands available in MySQL, see “SQL Statement
Syntax” in the MySQL 5.0 Reference Manual, which can be found at:
http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html
6. To delete the database, use the mysqladmin command as follows:
# mysqladmin –u root –p drop osmsdb
CAUTION: This command permanently removes all the tables and data contained in the
specified database. Use the mysqladmin drop command with caution.
7. Enter the database root password, at the prompt.
8. Enter y to confirm deletion of the database. The following should be displayed:
# mysqladmin -u root -p drop osmsdb
Enter password:
Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.
Do you really want to drop the 'osmsdb' database [y/N] y
Database "osmsdb" dropped
Administering User Accounts
This section describes how to administer user accounts on the MySQL server, including how to
set up new accounts, remove existing accounts, and grant access rights to a user account.
Managing the MySQL Database 11