MySQL 新增 User (Grant)

  • GRANT ALL ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
  • GRANT SELECT,INSERT,UPDATE,DELETE,CREATE ON db_name.* TO 'username'@'localhost' IDENTIFIED BY 'password';
  • GRANT ALL PRIVILEGES ON *.* TO 'username'@'127.0.0.%' IDENTIFIED BY 'password' WITH GRANT OPTION;
  • GRANT REPLICATION SLAVE ON *.* TO repl@"192.168.1.%" IDENTIFIED BY 'password';
  • GRANT SELECT,INSERT,UPDATE,DELETE,CREATE ON db_name.* TO 'username'@'%' IDENTIFIED BY 'password';
  • GRANT SELECT, LOCK TABLES ON *.* TO  'backup'@'localhost'
    IDENTIFIED BY 'backup_password'; # mysqldump
  • GRANT SELECT ON *.* TO  'backup'@'localhost'
    IDENTIFIED BY 'backup_password'; # mysqldump
  • FLUSH PRIVILEGES;

自行把 上述的 username, password, db_name 換掉即可.

說明

  • GRANT ALL ON *.* TO 'username'@'localhost' IDENTIFIED BY 'passowrd'
  • ALL: 授權的權限(SELECT, INSERT .... etc)
  • *.*: Table Name, Db_name.*, 指定可以存取哪些Db/Table
  • username: 要新增的 username
  • localhost: 可從哪邊來存取, 可用 % (% 代表全部)
  • password: 密碼

移除帳號

  • DROP USER username@'123.123.123.%';
  • DROP USER username@localhost;
  • DROP USER username;

關於 Tsung

對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.
本篇發表於 My_Note-App-Setting。將永久鏈結加入書籤。

MySQL 新增 User (Grant) 有 3 則回應

  1. 通告: [Mysql] Grant 身份與權限設定 | HelloMing – 僅記錄,不迷網

  2. 通告: MySQL 帳號權限(Grant)的移除、修改 - Tsung's Blog

  3. 通告: CentOS 7+Nginx+PHP+MariaDB 安裝全攻略 @ 工程濕(X)筆記

發表迴響