登陸mysqlmysql
GRANT ALL PRIVILEGES ON *.* TO 'username'@'IP' IDENTIFIED BY 'password';
這裏的IP填寫能訪問數據庫的ip地址, 若是須要全部地址都能訪問,則填%sql
GRANT ALL ON db.* TO 'username'@'192.168.12.10' IDENTIFIED BY "123456"; GRANT ALL ON db.table TO 'username'@'192.168.12.%' IDENTIFIED BY "123456"; GRANT ALL ON db.* TO 'username'@'192.168.12.0/24' IDENTIFIED BY "123456"; GRANT ALL ON *.* TO 'username'@'%' IDENTIFIED BY "123456";
而後刷新權限數據庫
FLUSH PRIVILEGES;
附建立用戶bash
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass'; CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';
查看mysql用戶遠程鏈接blog
select Host,User,Password from mysql.user;
刪除遠程用戶受權ip