1句指令建立 MySQL User
這篇文章會教大家如何建立MySQL User
建立MySQL使用者
CREATE USER 'newuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
給使用者設定限權
GRANT PRIVILEGE ON database.table TO 'username'@'host';
下選擇指定限權
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
所有資料庫全限權
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;
特定資料庫的限權
GRANT ALL PRIVILEGES ON database.* TO 'user'@'localhost' WITH GRANT OPTION;