Class Exercise: MySQL User and Table Administration
Objective: Show how to use the MySQL client (aka monitor) for command prompt
interaction with the MySQL database management system. (Note: use a semicolon
as a statement terminator.)
0. Login as the root user.
type: mysql -u root;
1. Check user and password settings:
type: use mysql;
select host,user,password from user;
2. Set passwords.
type: set password for root@localhost = password('new-password');
(It is also recommended to set the password for pma--PHPMyAdmin and other
users.)
3. Drop anonymous users.
type drop user ''@hostName; --note substitute localhost or other hostName
4. Create a database for development.
type: create database databaseName;
5. Set up a regular developer account to create and manipulate tables in the
database created(i.e. to avoid risks when working as root).
Type:
grant all|create, insert, ... on databaseName.*
to 'userName'@'localhost'
identified by 'password'):
6. Logout (exit, quit) and login as a regular user.
Type: exit;
mysql -u userName -p
7. Issue a command to use your database.
Type: use databaseName;
8. Show how to enter SQL commands to create a table, insert data into the table,
then select, update, and delete data from the table(see "File Operations").
9. Rename the table created.
Type alter table tableName rename to newTableName;
A. Describe the column or field properties for the table created.
Type show create table tableName;
B. Use the alter command to modify a table attribute. Type:
alter table tableName modify columnName columnType);
C. Exit mysql.