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

Detailed tutorial on how to create a user in mysql and grant user permissions

Table of contents User Management Create a new us...

A brief discussion on the lazy loading attribute pattern in JavaScript

Table of contents 1. Introduction 2. On-demand at...

Vue.js implements calendar function

This article example shares the specific code of ...

In-depth understanding of MySQL master-slave replication thread state transition

Preface The basic principle of MySQL master-slave...

WeChat applet implements search function and jumps to search results page

Search Page: search.wxml page: <view class=&qu...

MySQL cursor principle and usage example analysis

This article uses examples to explain the princip...

Have you really learned MySQL connection query?

1. Inner Join Query Overview Inner join is a very...

Solve the abnormal error when building vue environment with webpack

Table of contents First, configure package.json T...

mysql batch delete large amounts of data

mysql batch delete large amounts of data Assume t...

Method example of safely getting deep objects of Object in Js

Table of contents Preface text parameter example ...

Use of Linux ipcs command

1. Command Introduction The ipcs command is used ...

Detailed explanation of CocosCreator project structure mechanism

Table of contents 1. Project folder structure 1. ...

A screenshot demo based on canvas in html

Written at the beginning I remember seeing a shar...

HTML css js implements Tab page sample code

Copy code The code is as follows: <html xmlns=...

Detailed explanation of JavaScript data types

Table of contents 1. Literals 1.1 Numeric literal...