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 User Management Create a new us...
Table of contents 1. Introduction 2. On-demand at...
This article example shares the specific code of ...
Preface The basic principle of MySQL master-slave...
Search Page: search.wxml page: <view class=&qu...
This article uses examples to explain the princip...
1. Inner Join Query Overview Inner join is a very...
Table of contents First, configure package.json T...
mysql batch delete large amounts of data Assume t...
Table of contents Preface text parameter example ...
1. Command Introduction The ipcs command is used ...
Table of contents 1. Project folder structure 1. ...
Written at the beginning I remember seeing a shar...
Copy code The code is as follows: <html xmlns=...
Table of contents 1. Literals 1.1 Numeric literal...