Mysql設(shè)置用戶指定ip地址操作數(shù)據(jù)庫的方法:使用grant函數(shù),語法為【grant priv_type on mysql.user to 'user'@'host' identified by 'password' with】。
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供凌云網(wǎng)站建設(shè)、凌云做網(wǎng)站、凌云網(wǎng)站設(shè)計、凌云網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、凌云企業(yè)網(wǎng)站模板建站服務(wù),10余年凌云做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。
Mysql設(shè)置用戶指定ip地址操作數(shù)據(jù)庫的方法:
語法:
grant priv_type on mysql.user to 'user'@'host' identified by 'password' with grant option;
priv_type:代表允許操作數(shù)據(jù)庫的權(quán)限
user:代表數(shù)據(jù)庫用戶名
host:代表IP地址
password:代表設(shè)置的密碼
刷新user權(quán)限表:flush privileges;
三、案例
1、設(shè)置所有數(shù)據(jù)庫、所有表、任意ip可以連接數(shù)據(jù)庫,授權(quán)給用戶名ping并設(shè)置密碼為123456
grant all on *.* to 'ping'@'%' identified by '123456'; flush privileges;
2、授權(quán)表cloud的記錄修改權(quán)限給連接ip地址是192.168.100.1和用戶名是ping并且密碼為123456
grant update(name,sex) on cloud to 'ping'@'192.168.100.1' identified by '123456'; flush privileges;
四、查看數(shù)據(jù)庫權(quán)限表
mysql> select * from mysql.user where host='localhost'\\G; *************************** 1. row *************************** Host: localhost User: Password: Select_priv: N Insert_priv: N Update_priv: N Delete_priv: N Create_priv: N Drop_priv: N Reload_priv: N Shutdown_priv: N Process_priv: N File_priv: N Grant_priv: N References_priv: N Index_priv: N Alter_priv: N Show_db_priv: N Super_priv: N Create_tmp_table_priv: N Lock_tables_priv: N Execute_priv: N Repl_slave_priv: N Repl_client_priv: N Create_view_priv: N Show_view_priv: N Create_routine_priv: N Alter_routine_priv: N Create_user_priv: N Event_priv: N Trigger_priv: N ssl_type: ssl_cipher: x509_issuer: x509_subject: max_questions: 0 max_updates: 0 max_connections: 0 max_user_connections: 0
更多相關(guān)免費學(xué)習(xí)推薦:mysql教程(視頻)