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 ================================ Authorize the root user to all connections: grant all privileges on *.* to 'root'@'%' identified by 'xxxxxx'; 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:
|
<<: 15 Linux Command Aliases That Will Save You Time
>>: Install Apple Mac OS X in VMWare12 Graphic Tutorial
Table of contents Preface Optional Chaining Nulli...
Preface After reading the previous article about ...
Preface Linux does not have a prominent Recycle B...
Preface: Today I want to remotely connect to MySQ...
Preface MySQL officially refers to prepare, execu...
Written in advance: In the following steps, you n...
Table of contents 1. Comments on MySQL primary ke...
Counting the size of each table in each database ...
Table of contents Where are the logs stored? View...
Table of contents Preface Rationale Procedure 1. ...
When exporting data to operations, it is inevitab...
Building an image is a very important process in ...
First, download the green free installation versi...
The previous articles introduced how to debug loc...
mysql accidentally deleted data Using the delete ...