Two methods to implement Mysql remote connection configuration

Two methods to implement Mysql remote connection configuration

Two methods to implement Mysql remote connection configuration

When we work in the company, we often encounter MySQL databases stored on someone's computer. If we want to connect to the MySQL service, the computer with the MySQL service installed must open a remote connection.

The first one:

root@ubuntu:/usr/local/MySQL# mysql -hlocalhost -uroot -proot;

mysql>use mysql;

mysql>insert into user (
 host,
 user,
 password,
 Select_priv,
 Insert_priv,
 Update_priv,
 Delete_priv,
 Create_priv,
 Drop_priv,
 Reload_priv,
 Shutdown_priv,
 Process_priv,
 File_priv,
 Grant_priv,
 References_priv,
 Index_priv,
 Alter_priv,
 Show_db_priv,
 Super_priv,
 Create_tmp_table_priv,
 Lock_tables_priv,
 Execute_priv,
 Repl_slave_priv,
 Repl_client_priv,
 Create_view_priv,
 Show_view_priv,
 Create_routine_priv,
 Alter_routine_priv,
 Create_user_priv,
 Event_priv,
 Trigger_priv,
 Create_tablespace_priv
)VALUES (
'%', //Fixed IP replaces %
'cap',
password('cap'),
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y',
'Y'
);

mysql> FLUSH PRIVILEGES;

Second type:

root@ubuntu:/usr/local/mysql#mysql
 -hlocalhost -uroot -proot;

mysql>GRANT ALL PRIVILEGES ON *.* TO 'test'@'%'IDENTIFIED BY 'test' WITH GRANT OPTION; //Replace % if using fixed IP


mysql> FLUSH PRIVILEGES;

Thank you for reading, I hope it can help you, thank you for your support of this site!

You may also be interested in:
  • MySQL gets the current date and time function
  • A simple way to change the password in MySQL 5.7
  • Detailed explanation of Python MySQL database connection pool component pymysqlpool
  • Detailed tutorial on customizing the installation path of MySQL 5.7.18 version (binary package installation)
  • Use node and express to connect to mysql to implement login and registration code
  • Tutorial on how to deploy php7.1 and enable MySQL extension under CentOS 7

<<:  Detailed explanation of how to exit Docker container without closing it

>>:  Two ways to use react in React html

Recommend

How to remove the dotted border when clicking a link in FireFox

I encountered several browser compatibility issue...

Advantages and disadvantages of conditional comments in IE

IE's conditional comments are a proprietary (...

uniapp realizes the recording upload function

Table of contents uni-app Introduction HTML part ...

mysql zip file installation tutorial

This article shares the specific method of instal...

Invalid solution when defining multiple class attributes in HTML

In the process of writing HTML, we often define mu...

JavaScript to achieve digital clock effect

This article example shares the specific code of ...

Call and execute host docker operations in docker container

First of all, this post is dedicated to Docker no...

Introduction to the use of select optgroup tag in html

Occasionally, I need to group select contents. In ...

The benefits and examples of placing the site map at the bottom of the web page

In the past, almost every website had a sitemap p...

Mysql uses stored procedures to quickly add millions of data sample code

Preface In order to reflect the difference betwee...

Detailed explanation of MySQL DEFINER usage

Table of contents Preface: 1.Brief introduction t...

How to configure ssh to log in to Linux using git bash

1. First, generate the public key and private key...

JS implements random roll call system

Use JS to implement a random roll call system for...

MySQL 5.7.23 installation and configuration graphic tutorial

This article records the detailed installation pr...

Command to view binlog file creation time in Linux

Table of contents background analyze method backg...