美文网首页Linux
Mysql新建用户及权限设置

Mysql新建用户及权限设置

作者: 沧海一粟_czs | 来源:发表于2018-12-22 18:26 被阅读0次

    一:登录mysql

    [root@chf chf]# mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 8
    Server version: 5.7.24 MySQL Community Server (GPL)
    Copyright (c) 2000, 2018, 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> 
    

    二:创建用户

    // @'%' 表示接受远程访问,若只允许本机访问,改为  @'localhost' 
    mysql> create user 'youe_user'@'%' identified by 'your_passwd'; 
    

    三:创建数据库

    // 查看目前现有数据库
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    6 rows in set (0.00 sec)
    
    //新建一个数据库
    mysql> create database your_database; 
    

    四:赋予用户数据库权限

    // 将某个数据库的权限全部赋予某一个用户
    mysql> grant all on your_databse.* to your_user@'%';
    mysql> flush privileges;
    

    相关文章

      网友评论

        本文标题:Mysql新建用户及权限设置

        本文链接:https://www.haomeiwen.com/subject/ftcwkqtx.html