CSC 411/511: DBMS Design Dr. Nan Wang 1 Database Administration

Preview:

Citation preview

CSC 411/511: DBMS Design

Dr. Nan Wang 1

Database Administration

Dr. Nan Wang 2

Account Management Statements

• Create user– CREATE USER user [IDENTIFIED BY [PASSWORD]

'password'] [, user [IDENTIFIED BY [PASSWORD] 'password']]…

• Drop user– DROP USER user [, user] ...

• Grant• Rename user

– RENAME USER old_user TO new_user [, old_user TO new_user] ...

• Revoke• Set password

– SET PASSWORD [FOR user] = { PASSWORD('some password') | OLD_PASSWORD('some password') | 'encrypted password' }

Dr. Nan Wang

Grant-give privileges on an object to a user

3

Dr. Nan Wang

examples

4

Dr. Nan Wang

Revoke-remove privileges on an object from a user

5

GRANT OPTION FOR option revokes the ability of the identified users to grant the specified privilege(s) to other users

Dr. Nan Wang

PUBLIC-grant a privilege to all users

6

Dr. Nan Wang

ROLE/GROUP

• create a role that represents a type of database user and assign privileges to that role.

• CREATE ROLE <role name> [WITH ADMIN OPTION]

7

Dr. Nan Wang

Revoke

8

DROP ROLE <role>

Dr. Nan Wang

Practise

9

Dr. Nan Wang

MySQL Administrator

10

Dr. Nan Wang

User Account

11

Dr. Nan Wang

Connecting to and Disconnecting from the Server• shell>mysql -h host -u user -p • mysql> QUIT

• MySQL Server:– Mysqld: mysql server– Mysqld_safe: mysql server startup script– Mysql.server: mysql server startup script– Mysqld_multi: manage multiple mysql servers

– http://dev.mysql.com/doc/refman/5.1/en/programs-server.html

12

Dr. Nan Wang

Server information

13

Dr. Nan Wang

Server Control

14

Dr. Nan Wang

Server Control

15

Dr. Nan Wang

Backup

• SELECT * INTO OUTFILE 'file_name' FROM

tbl_name.

• mysqldump --tab=/path/to/some/dir --opt

db_name

• mysqlhotcopy db_name /path/to/some/dir

16

Dr. Nan Wang

Backup

17

Dr. Nan Wang

Restore

18

Dr. Nan Wang

 Using mysql in Batch Mode

• shell> mysql < batch-file

• C:\> mysql -e "source batch-file"

• shell> mysql -h host -u user -p < batch-file

Enter password: ********

• shell> mysql < batch-file > mysql.out

• mysql> source filename

• mysql> \. filename 19

Dr. Nan Wang

Load data

• LOAD DATA INFILE '/tmp/test.txt'

INTO TABLE test

FIELDS TERMINATED BY ','

LINES STARTING BY ‘\n\r';

20

Recommended