發表文章

目前顯示的是 4月, 2023的文章

mysql 查詢 user 帳號及權限

圖片
  查有哪些帳號 SELECT User,Host FROM mysql.user; 查帳號權限 SHOW GRANTS FOR backuper; . 首頁 MySQL安全性 MySQL使用者權限設定 MySQL使用者權限設定 web - 5月 31, 2018 MySQL使用者權限資訊用user、db、host、tables_priv和columns_priv表被儲存在mysql資料庫中。 關於使用者權限的相關指令,說明如下 (1)使用 root 進入 MySQL mysql> mysql -u root -p (2)遠端登入 mysql> mysql -u root -h  remote_host_ip  -p remote_host_ip  指你要登入的遠端MySQL (3)修改使用者密碼 mysql> SET PASSWORD FOR  '目標使用者'@'主機'  = PASSWORD(' 密碼 '); mysql> flush privileges; (4)建立使用者,並給予權限 grant usage on *.* to  'username'@'localhost'  identified by ' yourpassword ' with grant option;  grant all privileges on *.* to  'username'@'localhost'  identified by ' yourpassword '; flush privileges; INSERT INTO user(host,user,password) VALUES(' % ',' username ',password(' userpassword ')); GRANT ALL ON *.* TO  'username'@localhost  IDENTIFIED BY  ' userpassword '  WITH GRANT OPTION; FLUSH PRIVILEGES; GRANT SELECT,I