mysql5.7. 17 Open Remote 3306 Port under ubuntu 16.04
- 2021-07-01 08:20:19
- OfStack
Turn on remote access rights for MySQL
By default, mysql users do not have remote access rights, so when the program and database are not on the same server, we need to turn on the remote access rights of mysql.
There are two mainstream methods, table change method and authorization method.
Relatively speaking, it is easier to change the table. Individuals also tend to use this method. Therefore, only the table change method is posted here
1. Log in to mysql
mysql -u root -p
2. Modify the user table of the mysql library, and change the host entry from localhost to%. % here means that any host is allowed to access. If only one ip is allowed to access, it can be changed to the corresponding ip. For example, localhost can be changed to 192.168. 1.123, which means that only the ip of LAN 192.168. 1.123 is allowed to remotely access mysql.
mysql> use mysql;
mysql> select host,user form user;
mysql>update user set host = '%' where user ='root';
mysql>select host,user from user;
mysql> flush privileges;
mysql> quit;
First check if the port is open netstat-angrep 3306
Open the mysql configuration file vim/etc/mysql/mysql. conf. d/mysqld. cnf
Unregister bind-address = 127.0. 0.1
Restart ubuntu
Check again if the port is open netstat-angrep 3306
================================
Authorize the root user to all connections: grant all privileges on *. * to 'root' @ '%' identified by 'xxxxxx';
The last one is the mysql password
Let the permissions take effect immediately: flush privileges; In fact, in fact, the
At this point, the operation is complete, and you can connect to this mysql database server on any host.
Solution of remote connection of MySQL: https://www.ofstack.com/article/103770. htm
Centos7.1 Firewall Open Port: https://www.ofstack.com/article/103777.htm
CentOS 7 Open Port: https://www. ofstack. com/article/103773. htm
ubuntu 15.04 mysql Open Remote 3306 Port: https://www.ofstack.com/article/103784. htm
https://www.ofstack.com/article/103766.htm
root@3bc476b7e0d5:~# vim /etc/mysql/mysql.conf.d/mysqld.cnf
root@3bc476b7e0d5:~# netstat -an | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
root@3bc476b7e0d5:/# service mysql enable
Usage: /etc/init.d/mysql start|stop|restart|reload|force-reload|status
root@3bc476b7e0d5:/# netstat -an | grep 3306
tcp6 0 0 :::3306 :::* LISTEN
root@3bc476b7e0d5:/# mysql --version
mysql Ver 14.14 Distrib 5.7.16, for Linux (x86_64) using EditLine wrapper
root@3bc476b7e0d5:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.16-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
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 |
| fabric |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.02 sec)