Home | Mirror | Search

第 4 章 Database Administration

目錄

1. User Account Management
1.1. Create User
1.2. Drop User
1.3. Rename User
1.4. SET PASSWORD
1.5. Reset root password
2. Access Privilege System
2.1. SHOW GRANTS
2.2. show privileges
2.3. Grant privileges
2.4. Revoke privileges
2.5. Show Privileges
2.6. MAX_QUERIES_PER_HOUR/MAX_UPDATES_PER_HOUR
3. Maintenance 資料庫維護
3.1. CHECK 檢查表
3.2. ANALYZE 分析表
3.3. CHECKSUM
3.4. OPTIMIZE 優化表
3.5. REPAIR 修復
4. SHOW COMMAND
4.1. 查看版本
4.2. status
4.2.1. show status
4.2.2. show master status
4.2.3. show slave status
4.2.4. show plugins
4.3. variables
4.3.1. wait_timeout
4.3.2. table_lock_wait_timeout
4.3.3. low_priority_updates
4.3.4. character_set
4.3.5. datadir
4.3.6. storage_engine
4.4. binary

1. User Account Management

1.1. Create User

CREATE USER user [IDENTIFIED BY [PASSWORD] 'password']
    [, user [IDENTIFIED BY [PASSWORD] 'password']] ...
			
CREATE USER 'test'@'xxx.xxx.xxx.xxx' IDENTIFIED BY  'your_password';
			

add a new user by grant

			
GRANT ALL PRIVILEGES ON opencart.* TO 'neo'@'localhost' IDENTIFIED BY 'chen' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON *.* TO 'neo'@'localhost' IDENTIFIED BY 'chen' WITH GRANT OPTION;

FLUSH PRIVILEGES;
			
			

1.2. Drop User

DROP USER user [, user] ...
			
			
mysql> drop user admin@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> drop user admin@'127.0.0.1';
Query OK, 0 rows affected (0.00 sec)
			
			

1.3. Rename User

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

1.4. SET PASSWORD

SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');

SET PASSWORD FOR 'root'@'%' = PASSWORD('co2uqAMAho1aSOS62146Xoci6ogu4I');
			
CREATE USER 'root'@'192.168.1.%' IDENTIFIED BY 'password';
			

1.5. Reset root password

忘記root密碼是使用

			
shell>mysqld_safe --skip-grant-tables &
shell>mysqladmin -u root flush-privileges password "newpassword"
			
			
comments powered by Disqus