使用mysql建立資料庫
以下四步分别為:登入,檢視已有資料庫,檢視MySQL版本,建立新資料庫并命名(我這裡命名為gasstation)
mysql -u root -p
show databases;
show variables like 'version';
create database gassation;
MySQL建立使用者
注意替換資料庫名,密碼
CREATE USER ‘gasstation'@'host' IDENTIFIED BY '123456';
MySQL使用者授權
grant 限權清單 on 庫名. to 使用者名@"用戶端位址" identified by "123456" with grant option;
- 限權清單
all ——————————————所有限權
usage ——————————————無限權
select,update,insert ——————————————個别限權
select,update(字段1,...,字段N)—————————指定限權
- 庫名
*.* ———————————— 所有庫所有表
庫名.* ———————————— 一個庫
庫名.表名 ———————————— 一個表
- 用戶端常用位址
% —————————— 所有主機
192.168.2.% —————————— 一個網段内所有主機
192.168.2.1 —————————— 指定的一台主機
localhost —————————— 資料庫伺服器本機