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; # 查看是否可見指定庫,有則成功