How to modify mysql permissions to allow hosts to access

How to modify mysql permissions to allow hosts to access

Enable remote access rights for 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> update user set host = '%' where user = 'root'; 
mysql> select host, user from user; 
mysql> flush privileges;

Open port 3306 on the firewall

Summarize

The above is what I introduced to you about modifying the permissions allowed by MySQL to allow hosts to access. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Detailed explanation of the solution to the error in creating a user and granting permissions in mysql8.0
  • How to open external network access rights for mysql
  • Detailed explanation of MySQL user rights verification and management methods
  • Summary of MySQL stored procedure permission issues
  • Solution to the problem that the configuration file my.cnf in MySQL cannot be started due to permission issues
  • Detailed explanation of using Dockerfile to build MySQL image and implement data initialization and permission setting
  • Example of how to create a local user in mysql and grant database permissions
  • Some notes on mysql create routine permissions
  • Enable remote access rights for MySQL under Linux and open port 3306 in the firewall
  • Mysql: The user specified as a definer (''xxx@''%'') does not exist solution

<<:  Detailed explanation of log processing of Docker containers

>>:  express project file directory description and detailed function description

Recommend

Detailed explanation of how to mount remote file systems via SSH on Linux

Features of SSHFS: Based on FUSE (the best usersp...

Detailed explanation of Truncate usage in MYSQL

This article guide: There are two ways to delete ...

Analysis of Linux kernel scheduler source code initialization

Table of contents 1. Introduction 2. Basic Concep...

How to use CSS styles and selectors

Three ways to use CSS in HTML: 1. Inline style: s...

Hadoop 2.x vs 3.x 22-point comparison, Hadoop 3.x improvements over 2.x

Question Guide 1. How does Hadoop 3.x tolerate fa...

Detailed tutorial on installing MySQL 8.0 from source code on CentOS 7.4

Table of contents 1. Environment 2. Preparation 3...

Full steps to create a password generator using Node.js

Table of contents 1. Preparation 2. Writing comma...

Three properties of javascript objects

Table of contents 1. writable: writable 2. enumer...

Vue3.0+vite2 implements dynamic asynchronous component lazy loading

Table of contents Create a Vite project Creating ...

MySQL 5.7.12 installation and configuration tutorial under Mac OS 10.11

How to install and configure MySQL on Mac OS 10.1...

VMware, nmap, burpsuite installation tutorial

Table of contents VMware BurpSuite 1. Virtual mac...

Node.js solves the problem of Chinese garbled characters in client request data

Node.js solves the problem of Chinese garbled cha...

About CSS floating and canceling floating

Definition of Float Sets the element out of the n...

HTML thead tag definition and usage detailed introduction

Copy code The code is as follows: <thead> &...