| mysql用户 | linux用户 |
作用 | 登录mysql数据库; 管理mysql对象 | 登录linux系统; 管理linux对象 |
特点 | 用户名@'白名单'(白名单指的是地址列表,允许白名单的ip登录mysql,管理mysql) | 用户名 |
guest@'localhost' guest通过本地登录(socket)
guest@'10.0.0.10' guest通过 10.0.0.10远程登录mysql服务器
guest@'10.0.0.%' guest通过10.0.0.xx/24远程登录mysql服务器
guest@'10.0.0.5%' guest通过10.0.0.50-59远程登录路
guest@'10.0.0.0/255.255.254.0'
用户管理(增删改查)
查
mysql> select user,host,authentication_string from mysql.user; +------------------+-----------+-------------------------------------------+ | user | host | authentication_string | +------------------+-----------+-------------------------------------------+ | mysql.infoschema | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | root | localhost | | +------------------+-----------+-------------------------------------------+ 4 rows in set (0.00 sec)
增
mysql> create user guest@'localhost' identified by '123'; Query OK, 0 rows affected (0.04 sec)
改
mysql> alter user guest@'localhost' identified by '456';
删
mysql> drop user guest@'localhost'; Query OK, 0 rows affected (0.10 sec)
8.0版本以前,可以通过grant命令建立用户+授权。