加入收藏 | 设为首页 | 会员中心 | 我要投稿 聊城站长网 (https://www.0635zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

MySQL 5.7中怎么创建用户并授权

发布时间:2022-02-10 13:29:25 所属栏目:MySql教程 来源:互联网
导读:这期内容当中小编将会给大家带来有关MySQL 5.7中怎么创建用户并授权,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。 --创建用户 mysql create user test@% identified by System#2013; Query OK, 0 rows affected (0
        这期内容当中小编将会给大家带来有关MySQL 5.7中怎么创建用户并授权,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
 
--创建用户
 
mysql> create user 'test'@'%' identified by 'System#2013';
Query OK, 0 rows affected (0.00 sec)
 
mysql> select host,user from mysql.user;
+-----------+-----------+
| host      | user      |
+-----------+-----------+
| %         | test      |
| localhost | jeffrey   |
| localhost | mysql.sys |
| localhost | root      |
+-----------+-----------+
4 rows in set (0.00 sec)
 
--授予对TEST数据库的操作权限
 
mysql> GRANT ALL ON test.* TO 'test'@'%';
Query OK, 0 rows affected (0.01 sec)
 
--测试新创建的用户
 
[root@T400-kelong ~]# mysql -utest -pSystem#2013
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 6
Server version: 5.7.10-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2015, 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> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
 
mysql> CREATE TABLE client_firms (
    ->     id   INT,
    ->     name VARCHAR(35)
    -> )
    -> PARTITION BY LIST (id) (
    ->     PARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21),
    ->     PARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22),
    ->     PARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23),
    ->     PARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24)
    -> );
Query OK, 0 rows affected (0.15 sec)
 
上述就是小编为大家分享的MySQL 5.7中怎么创建用户并授权了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。

(编辑:聊城站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!