Linux(三十一)centos 7 mysql远程登录权限

安装好mysql or mariadb后就使用界面管理工具进行管理了,推荐管理工具:SQLyog 、 Navicat for MySQL

1、防火墙要开放3306端口

2、对远程用户授权

[root@localhost backup]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.07 sec)

MariaDB [(none)]> grant all privileges on *.* to ‘TQ‘@‘192.168.85.1‘ identified by ‘密码‘;
Query OK, 0 rows affected (0.05 sec)

MariaDB [(none)]> grant all privileges on *.* to ‘root‘@‘192.168.85.1‘ identified by ‘密码‘;
Query OK, 0 rows affected (0.03 sec)

 

3、远程工具连接

技术分享

 

4、取消对远程用户的授权

MariaDB [(none)]> use mysql;
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

MariaDB [mysql]> revoke all privileges on *.* from [email protected];
Query OK, 0 rows affected (0.00 sec)

 

MariaDB [mysql]> delete from user where user=‘TQ‘;//记住删除用户,否则可以连接
Query OK, 1 row affected (0.03 sec)

MariaDB [mysql]> flush privileges;//更新权限表
Query OK, 0 rows affected (0.03 sec)

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。