5.7.27版本mysql新增用戶


  因為我們目前只有root,所以只能先用root登陸mysql,再新增用戶:

$ bin/mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.27 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> insert into mysql.user(Host,User,ssl_cipher,x509_issuer,x509_subject) values('localhost', 'wlf','','','');
Query OK, 1 row affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

  接着我們給新用戶wlf設置密碼:

mysql> set password for 'wlf'@'localhost' = password('wlf123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

  然后我們新建數據庫,並給wlf用戶賦予權限,登陸口令跟wlf的密碼一致:

mysql> create database nacos_config;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on nacos_config.* to wlf@localhost identified by 'wlf123';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

  用wlf登陸后查看數據庫,發現nacos_config已經建好了

[wlf@zjhz-cmread-test188 mysql]$ bin/mysql -u wlf -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.27 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| nacos_config       |
+--------------------+
2 rows in set (0.00 sec)

 


免責聲明!

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



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