Ubuntu 16.04 mysql5.7.17 open remote port 3306

Ubuntu 16.04 mysql5.7.17 open remote port 3306

Enable remote access to MySQL

By default, MySQL users do not have remote access permissions, so when the program and the database are not on the same server, we need to enable remote access permissions for MySQL.

There are two mainstream methods, the table modification method and the authorization method.

Relatively speaking, the table modification method is easier, and I personally prefer this method. Therefore, I will only post the table modification method here.

1. Log in to MySQL

mysql -u root -p

2. Modify the user table of the MySQL database and change the host item from localhost to %. %This means that any host is allowed to access. If only a certain IP is allowed to access, you can change it to the corresponding IP. For example, you can change localhost to 192.168.1.123, which means that only the IP 192.168.1.123 in the local area network 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 -an | grep 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 whether the port is open netstat -an | grep 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;​

Now all operations are completed and you can connect to this MySQL database server from any host.

Solution to MySQL remote connection failure: https://www.jb51.net/article/103770.htm

Centos7.1 firewall open port: https://www.jb51.net/article/103777.htm

CentOS 7 open ports: https://www.jb51.net/article/103773.htm

Ubuntu 15.04 mysql opens remote port 3306 : https://www.jb51.net/article/103784.htm

https://www.jb51.net/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) 

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Install MySQL 5.7 on Ubuntu 18.04
  • Ubuntu16.04 installation mysql5.7.22 graphic tutorial
  • How to configure PHP7.0+Apache2+Mysql5.7 in Ubuntu14.04 server environment
  • Manually install mysql5.7.10 on Ubuntu
  • Tutorial on installing MySQL 5.7 on Ubuntu 16.04
  • MySQL 5.7.16 installation and configuration method graphic tutorial (Ubuntu 16.04)
  • MySQL 5.7.17 installation and configuration tutorial under Linux (Ubuntu)
  • MySQL 5.7.17 installation and configuration method graphic tutorial (Ubuntu 16.04)
  • Tutorial on installing multiple MySQL 5.7.14 under Ubuntu Kylin 14.10
  • Install mysql5.7 on Ubuntu 18.04

<<:  15 Linux Command Aliases That Will Save You Time

>>:  Install Apple Mac OS X in VMWare12 Graphic Tutorial

Recommend

A brief discussion of 3 new features worth noting in TypeScript 3.7

Table of contents Preface Optional Chaining Nulli...

How to implement remote automatic backup of MongoDB in Linux

Preface After reading the previous article about ...

How to solve the 10060 unknow error when Navicat remotely connects to MySQL

Preface: Today I want to remotely connect to MySQ...

Tutorial on using prepare, execute and deallocate statements in MySQL

Preface MySQL officially refers to prepare, execu...

Ubuntu 18.04 obtains root permissions and logs in as root user

Written in advance: In the following steps, you n...

Detailed explanation of primary keys and transactions in MySQL

Table of contents 1. Comments on MySQL primary ke...

Example to explain the size of MySQL statistics table

Counting the size of each table in each database ...

Detailed explanation of where Docker saves log files

Table of contents Where are the logs stored? View...

Mysql implements three functions for field splicing

When exporting data to operations, it is inevitab...

Solve MySQL deadlock routine by updating different indexes

The previous articles introduced how to debug loc...

Mysql accidental deletion of data solution and kill statement principle

mysql accidentally deleted data Using the delete ...