您好,登錄后才能下訂單哦!
一、新建用戶
//登錄MYSQL
root@log:~# mysql -uroot -p
Enter password: 密碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 138
Server version: 5.5.53-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
//創建用戶
mysql> insert into mysql.user(Host,User,Password) values ("localhost","zhouyuyao",password("Zhouyuyao123"));
mysql> insert into mysql.user(Host,User,Password) values ("%","zhouyuyao",password("Zhouyuyao123"));
//刷新系統權限表
mysql> flush privileges;
這樣就創建了一個名為:zhouyuyao 密碼為:Zhouyuyao123 的用戶。
二、登錄測試
mysql>exit;
@>mysql -u zhouyuyao -p
@>輸入密碼
mysql>登錄成功
三、用戶授權
//登錄MYSQL
@>mysql -u root -p
@>密碼
//首先為用戶創建一個數據庫(test)
mysql>create database test;
//授權zhouyuyao 用戶擁有test數據庫的所有權限
mysql> grant all privileges on test.* to zhouyuyao@'%' identified by 'Zhouyuyao123';
//刷新系統權限表
mysql> flush privileges;
mysql> 其它操作
四、部分授權
mysql>grant select,update on test.* to zhouyuyao@localhost
identified by ‘cplusplus.me';
//刷新系統權限表
mysql> flush privileges;
五、刪除用戶
@>mysql -u root -p
@>密碼
mysql>DELETE FROM user WHERE User=”zhouyuyao” and Host=”localhost”;
mysql> flush privileges;
六、刪除數據庫
mysql>drop database test;
七、修改密碼
@>mysql -u root -p
@>密碼
mysql>update mysql.user set password=password(‘新密碼’) where
User=”zhouyuyao” and Host=”localhost”;
mysql> flush privileges;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。