您好,登錄后才能下訂單哦!
這篇文章主要介紹mysql如何實現用戶創建,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
mysql> create database test;
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> create user 'chenyj'@'*' identified by 'chenyj';
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> grant all on test.* to chenyj@'*';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> grant all on test.* to 'chenyj'@'*';
Query OK, 0 rows affected (0.01 sec)
mysql> grant connect to 'chenyj'@'*';
ERROR 3523 (HY000): Unknown authorization ID `connect`@`%`
mysql>
mysql> create user 'chenyj'@'%' identified by 'chenyj';
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> grant all on test.* to 'chenyj'@'%';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
測試:
[root@mysql8-01 ~]# mysql -h localhost -u chenyj -p
Enter password:
ERROR 1045 (28000): Access denied for user 'chenyj'@'localhost' (using password: YES)
[root@mysql8-01 ~]#
[root@mysql8-01 ~]# mysql -h localhost -u chenyj -p
Enter password:
ERROR 1045 (28000): Access denied for user 'chenyj'@'localhost' (using password: YES)
[root@mysql8-01 ~]# mysql -h localhost -u chenyj -p
Enter password:
ERROR 1045 (28000): Access denied for user 'chenyj'@'localhost' (using password: YES)
[root@mysql8-01 ~]#
[root@mysql8-01 ~]# mysql -h localhost -u chenyj -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.14 MySQL Community Server - GPL
Copyright (c) 2000, 2019, 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>
mysql>
需要注意的是通配符應該采用'%'
以上是“mysql如何實現用戶創建”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。