HP OSMS Blueprint: Database Server on HP Server Platforms with MySQL and RHEL5
NOTE: In general, should set up a new account for any user or application that accesses the
MySQL server. This allows different users to have access to only the specific databases and tables
they need.
Setting Up a New Account
1. Start the MySQL command-line client by entering the following command:
# mysql –u root –p
2. At the prompt, enter the MySQL root password.
3. To create a database user, use the following command:
mysql> create user username ;
For example, enter the following:
mysql> create user osmsusr ;
CAUTION: This command creates a user named osmsusr, which can connect to the MySQL
database from any system.
4. To verify creation of the database user account, the following command is used:
mysql> show grants for username ;
For example, enter the following:
mysql> show grants for osmsusr ;
Removing a User Account
1. Start the MySQL command-line client by entering the following command:
# mysql –u root –p
At the prompt, enter the MySQL root password.
2. To delete a database user, use the following command:
mysql> drop user username ;
For example, enter the following:
mysql> drop user osmsusr ;
NOTE: The drop user command removes privilege rows for the user account from all grant
tables, but it does not automatically close any open user sessions. Therefore, if a user with an
open session is dropped, the command does not take effect until that user session is closed. After
the session is closed, the user is dropped. Thereafter, any attempts by the user to log in fail.
Granting Access Rights
Use the grant command to manage the access rights for a database user. You can grant each
MySQL user specific read and write permissions for every table and database stored in the
MySQL system. Additionally, you must run the flush command in order for the grant command
to take effect.
1. Start the MySQL command-line client by entering the following command:
# mysql –u root –p
At the prompt, enter the MySQL root password.
2. To grant privileges to a database user account, use the following command:
mysql> grant all privileges on database.* to username@'hostname' \
Managing the MySQL Database 13