zoukankan      html  css  js  c++  java
  • mysql新增用户

      新开了个项目,数据库也想新搞个用户,先登陆mysql,看看原来都有哪些:

    root@wlf:/# mysql -uroot -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 76766
    Server version: 5.7.26-log 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> select host,user from mysql.user;
    +-----------+---------------+
    | host      | user          |
    +-----------+---------------+
    | %         | backup        |
    | %         | hellodevelop     |
    | %         | hellocloud       |
    | %         | passerby      |
    | %         | hellomg         |
    | localhost | mysql.session |
    | localhost | mysql.sys     |
    | localhost | root          |
    +-----------+---------------+
    8 rows in set (0.00 sec)

      我们新增一个prize用户:

    mysql> create user 'prize'@'%' identified by 'prize';
    Query OK, 0 rows affected (0.11 sec)
    
    mysql> select host,user from mysql.user;
    +-----------+---------------+
    | host      | user          |
    +-----------+---------------+
    | %         | backup        |
    | %         | hellodevelop     |
    | %         | hellocloud       |
    | %         | passerby      |
    | %         | prize         |
    | %         | hellomg         |
    | localhost | mysql.session |
    | localhost | mysql.sys     |
    | localhost | root          |
    +-----------+---------------+
    9 rows in set (0.00 sec)

      

      但这会儿新用户是没有任何操作权限的,除了看看:

    mysql> show grants for 'prize'@'%';
    +-----------------------------------+
    | Grants for prize@%                |
    +-----------------------------------+
    | GRANT USAGE ON *.* TO 'prize'@'%' |
    +-----------------------------------+
    1 row in set (0.00 sec)

      

      所以我们还得给它赋予各种权限:

    mysql> grant all privileges on `prize`.* to 'prize'@'%';
    Query OK, 0 rows affected (0.04 sec)
    
    mysql> show grants for 'prize'@'%';
    +--------------------------------------------------+
    | Grants for prize@%                               |
    +--------------------------------------------------+
    | GRANT USAGE ON *.* TO 'prize'@'%'                |
    | GRANT ALL PRIVILEGES ON `prize`.* TO 'prize'@'%' |
    +--------------------------------------------------+
    2 rows in set (0.00 sec)

      刷新一下权限:

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

      现在可以进入prize用户开始我们的倒腾了:

    mysql> exit;
    Bye
    root@d5afa9102517:/# mysql -uprize -pprize
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 77055
    Server version: 5.7.26-log 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> create database prize;
    Query OK, 1 row affected (0.09 sec)
  • 相关阅读:
    调用外部程序主窗体做子窗体
    查看window编码
    c# 数据库更新和界面刷新的问题
    c# datagridview代码(网上的)
    winform DataGridView控件的打印
    西电ubuntu更新软件源
    C++ primer 学习笔记(2):函数
    C++ Primer 学习笔记(1)——迭代器,数组
    查询表属于哪个数据
    oracle 实用语句
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/12066237.html
Copyright © 2011-2022 走看看