5.7.27版本mysql新增用户

  1、需要root登陆mysql,再新增用户:

$ bin/mysql -u root -p
Enter password: 

  2、在表mysql.user新增用户:

mysql> insert into mysql.user(Host,User,ssl_cipher,x509_issuer,x509_subject) values('localhost', 'wlf','','','');

  3、新增后需要刷新:

mysql> flush privileges;

  4、给新用户设置密码:

mysql> set password for 'wlf'@'localhost' = password('wlf123');

  5、刷新:

mysql> flush privileges;

  6、给新用户新建一个数据库:

mysql> create database nacos_config;

  7、给新数据库赋予新用户的所有权限,刷新:

mysql> grant all privileges on nacos_config.* to wlf@localhost identified by 'wlf123';
mysql> flush privileges;

  8、用新用户登陆,使用新数据库:

$ 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       |
+--------------------+
rows in set (0.00 sec)

 

posted on 2019-09-20 13:23  不想下火车的人  阅读(1118)  评论(0编辑  收藏  举报

导航