数据库授权magedu用户,允许192.168.1.0/24网段可以连接mysql

MariaDB [hellodb]> GRANT ALL PRIVILEGES ON hellodb.* TO magedu@'192.168.1.%' IDENTIFIED BY 'centos';
MariaDB [hellodb]> FLUSH PRIVILEGES;
MariaDB [hellodb]> SHOW GRANTS FOR magedu@'192.168.1.%';
+-----------------------------------------------------------------------------------------------------------------+
| Grants for magedu@192.168.1.%                                                                                   |
+-----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `magedu`@`192.168.1.%` IDENTIFIED BY PASSWORD '*128977E278358FF80A246B5046F51043A2B1FCED' |
| GRANT ALL PRIVILEGES ON `hellodb`.* TO `magedu`@`192.168.1.%`                                                   |
+-----------------------------------------------------------------------------------------------------------------+

[root@centos7 ~]#ip a a 192.168.1.0/24 dev eth0
[root@centos7 ~]#mysql -umagedu -h192.168.1.0 -pcentos -Dhellodb
MariaDB [hellodb]> status
--------------
mysql  Ver 15.1 Distrib 10.4.22-MariaDB, for Linux (x86_64) using readline 5.1

Connection id:		11
Current database:	hellodb
Current user:		magedu@192.168.1.0
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server:			MariaDB
Server version:		10.4.22-MariaDB MariaDB Server
Protocol version:	10
Connection:		192.168.1.0 via TCP/IP
Server characterset:	utf8
Db     characterset:	utf8
Client characterset:	utf8
Conn.  characterset:	utf8
TCP port:		3306
Uptime:			17 min 36 sec





版权声明:本文为weixin_51867896原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。