4.数据库授权magedu用户,允许192.168.1.0/24网段可以连接mysql
2022/7/31 2:52:48
本文主要是介绍4.数据库授权magedu用户,允许192.168.1.0/24网段可以连接mysql,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
4.数据库授权magedu用户,允许192.168.1.0/24网段可以连接mysql
第一台主机上:
[root@centos8-8 ~]# hostname -I
192.168.1.8
[root@centos8-8 ~]# mysql -uroot -pMmagedu0!
(root@localhost) [(none)]> use mysql;
(root@localhost) [mysql]> show databases;
+--------------------+
| Database |
+--------------------+
| db1 |
| hellodb |
| information_schema |
| mysql |
| performance_schema |
| sys |
| zabbix |
+--------------------+
(root@localhost) [mysql]>create user magedu@'192.168.1.%' identified by 'Mmagedu0!';
(root@localhost) [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
(root@localhost) [mysql]>exit
++++++++++++++++++++
第二台主机上:
[root@centos8-18 ~]# systemctl start mysqld
[root@centos8-18 ~]# hostname -I
192.168.1.18
[root@centos8-18 ~]# mysql -umagedu -pMmagedu0! -h192.168.1.8
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 8
Server version: 8.0.26 Source distribution
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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 |
+--------------------+
1 row in set (0.01 sec)
第一台主机上授权:
[root@centos8-8 ~]# hostname -I
192.168.1.8
[root@centos8-8 ~]# mysql -uroot -pMmagedu0!
(root@localhost) [mysql]> grant all privileges on hellodb.* to 'magedu'@'192.168.1.%';
Query OK, 0 rows affected (0.00 sec)
(root@localhost) [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
第二台主机上再次登录:
[root@centos8-18 ~]# mysql -umagedu -pMmagedu0! -h192.168.1.8
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| hellodb |
| information_schema |
+--------------------+
2 rows in set (0.01 sec)
mysql> use hellodb;
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> show tables;
+-------------------+
| Tables_in_hellodb |
+-------------------+
| classes |
| coc |
| courses |
| scores |
| students |
| teachers |
| toc |
+-------------------+
7 rows in set (0.00 sec)
mysql> select * from scores;
+----+-------+----------+-------+
| ID | StuID | CourseID | Score |
+----+-------+----------+-------+
| 1 | 1 | 2 | 77 |
| 2 | 1 | 6 | 93 |
| 3 | 2 | 2 | 47 |
| 4 | 2 | 5 | 97 |
这篇关于4.数据库授权magedu用户,允许192.168.1.0/24网段可以连接mysql的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-24在Linux下管理MySQL的大小写敏感性
- 2024-04-26MySQL查出时间比实际晚8小时的解决方案
- 2024-04-01JPA不识别MySQL的枚举类型
- 2024-03-30mysql数据库表卡死解决方法
- 2024-03-15MySQL多数据源笔记5-ShardingJDBC实战
- 2024-03-11natural join mysql
- 2024-03-11关于VS2017,VS2015 中利用 EF使用Mysql 不显示数据源问题解决方案
- 2024-02-26mysql 阿里云xb后缀备份文件恢复-icode9专业技术文章分享
- 2024-02-22docker mysql 5.7
- 2024-02-18从 20 多套 MySQL 到 1 套 TiDB丨骏伯网络综合运营管理平台应用实践