mysql8.0 創建數據庫及對應的用戶


1、使用root用戶登入數據庫

2、創建數據庫

create dababase test_database

3、創建用戶

## % 代表不限制ip
## localhost 代表只能本地訪問
## 192.168.1.1 代表只能192.168.1.1 這個固定ip訪問
create user 'testuser'@'%' identified by 'testuser';

4、授權,允許新建用戶可以訪問當前數據庫

## all privileges 代表所有權限
## select,insert,update,delete,create,drop 代表具體權限
grant all privileges on test_database.* to 'testuser'@'%';

5、權限刷新

flush privileges;

# mysql 修改密碼

ALTER USER 'testuser'@'%' IDENTIFIED WITH mysql_native_password BY 'testuser111';
flush privileges;


免責聲明!

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



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