不多說直接上代碼
[root@demo /]# mysql -u root -p #登錄服務器數據庫 Enter password:123xxx #1.創建一個新用戶 testuser 密碼為 testuserpass CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'testuserpass';
#2.創建數據庫testDB create database testDB;
#3.執行命令為testuser用戶添加使用testDB權限 grant all privileges on testDB.* to testuser@localhost identified by 'testuserpass';
#4.執行命令,為testuser用戶添加遠程訪問權限 GRANT ALL PRIVILEGES ON testDB.* TO 'testuser'@'%' IDENTIFIED BY 'testuserpass' WITH GRANT OPTION;
#5.刷新權限表
flush privileges;