MySQL添加新用户、为用户创建数据库、为新用户分配权限
生活随笔
收集整理的這篇文章主要介紹了
MySQL添加新用户、为用户创建数据库、为新用户分配权限
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
https://blog.csdn.net/u013216667/article/details/70158452
登錄MySQL
mysql -u root -p添加新用戶
允許本地 IP 訪問 localhost, 127.0.0.1
create user 'test'@'localhost' identified by '123456';允許外網 IP 訪問
create user 'test'@'%' identified by '123456'; 刷新授權?
flush privileges;?
為用戶創建數據庫
?
create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;為新用戶分配權限
授予用戶通過外網IP對于該數據庫的全部權限
?
grant all privileges on `testdb`.* to 'test'@'%' identified by '123456'; 授予用戶在本地服務器對該數據庫的全部權限?
grant all privileges on `testdb`.* to 'test'@'localhost' identified by '123456';?
刷新權限 flush privileges; 退出 root 重新登錄exit 用新帳號 test 重新登錄,由于使用的是 % 任意IP連接,所以需要指定外部訪問IP mysql -u test -h 115.28.203.224 -p
?
在Ubuntu服務器下,MySQL默認是只允許本地登錄,因此需要修改配置文件將地址綁定給注釋掉:
?
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. #bind-address = 127.0.0.1 #注釋掉這一行就可以遠程登錄了?
總結
以上是生活随笔為你收集整理的MySQL添加新用户、为用户创建数据库、为新用户分配权限的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PHP 7.2 新功能介绍
- 下一篇: javascriptjquery 判断滚