启动mysql:
sudo service mysql start
停止mysql:
sudo service mysql stop
重启mysql:
sudo service mysql restart
查询user,host,plugin
mysql> select user,host,plugin from mysql.user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| bak | % | mysql_native_password |
| monitor | % | mysql_native_password |
| repuser | % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| repuser | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
8 rows in set (0.00 sec)
修改root的localhost为%
update user set host = '%' where user = 'root';
创建新用户
create user 'zxy'@'%' identified with mysql_native_password by 'password';
授权
grant all privileges on 数据库名.* to 'zxy'@'%';