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

Summary of Vue3 combined with TypeScript project development practice

Table of contents Overview 1. Compositon API 1. W...

Detailed explanation of the concept, principle and usage of MySQL triggers

This article uses examples to explain the concept...

Practice of multi-layer nested display of element table

There is a requirement for a list containing mult...

MySQL automatically inserts millions of simulated data operation code

I use Navicat as my database tool. Others are sim...

How to retrieve password for mysql 8.0.22 on Mac

Mac latest version of MySQL 8.0.22 password recov...

Several ways to manually implement HMR in webpack

Table of contents 1. Introduction 2. GitHub 3. Ba...

MySql 5.6.35 winx64 installation detailed tutorial

Note: There was no error in the project startup d...

Vue Element-ui implements tree control node adding icon detailed explanation

Table of contents 1. Rendering 2. Bind data and a...

Two-hour introductory Docker tutorial

Table of contents 1.0 Introduction 2.0 Docker Ins...

Analysis of basic usage of ul and li

Navigation, small amount of data table, centered &...

How can MySQL effectively prevent database deletion and running away?

Table of contents Safe Mode Settings test 1. Upda...

Example code for realizing charging effect of B station with css+svg

difficulty Two mask creation of svg graphics Firs...

A brief analysis of CSS :is() and :where() coming to browsers soon

Preview versions of Safari (Technology Preview 10...