mysql數據庫配置問題:授權指定庫給指定mysql賬號訪問


1.管理員對指定賬號進行授權

grant all privileges on 數據庫名.* to '賬號名'@'%' identified by '賬號密碼';

# 示例:
'''
數據庫名:shuchengyi
賬號名:shucheng
密碼:shucheng
'''
grant all privileges on shuchengyi.* to 'shucheng'@'%' identified by 'shucheng';

# 如要授權的賬戶未被創建則自動創建該賬號

2.如果本機連mysql連不上

# 就把賬號授權的代碼,用localhost替換%,本機就可以登錄了
grant all privileges on shuchengyi.* to 'shucheng'@'localhost' identified by 'shucheng';

3.設置完之后一定要刷新權限

flush privileges

4.退出管理員,用賬號 luffy 密碼 luffy 登入開發

mysql -ushucheng -pshucheng
show databases;  # 查看是否可見指定庫,有則成功


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM