How to connect to virtual machine MySQL using VScode in window environment

How to connect to virtual machine MySQL using VScode in window environment

1. Virtual Machine Side

1. Find the mysql configuration file

:sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

Press the "i" key to enter the edit mode, find the following item, and change the address to "0.0.0.0"


Restart mysql service

:sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

2. Connect to MySQL

:mysql -uroot -hlocalhost -p

Enter the code and press Enter, and you will be prompted to enter the database password

3. Authorize users

>>grant all privileges on *.* to 'username'@'%' identified by 'password' with grant option;

Can be root user

4. Refresh authorization

>>flush privileges;

2. Windows

1. Open VScode and install the following 2 plug-ins

This will appear in VScode


2. Now you can connect to the MySQL database

2.1 Enter the IP address of the virtual machine


If you don't know, you can use the following command to query

:ifconfig

2.2 Enter the username and password (the user and password previously authorized on the virtual machine)

2.3 Output port number (default 3306)

2.4 You don’t need to input this item, just press Enter

At this point you can see that VScode has connected to the MySQL database on the virtual machine.

The above is a detailed explanation and integration of the method of using VScode to connect to the virtual machine MySQL in the window environment introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor 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:
  • Manage databases with the MySQL extension for VS Code

<<:  In-depth understanding of JavaScript callback functions

>>:  Detailed tutorial on installing Tomcat9 windows service

Recommend

Detailed explanation of where the image pulled by docker is stored

20200804Addendum: The article may be incorrect. Y...

Detailed explanation of CentOS configuration of Nginx official Yum source

I have been using the CentOS purchased by Alibaba...

Problems and experiences encountered in web development

<br />The following are the problems I encou...

How to install vim editor in Linux (Ubuntu 18.04)

You can go to the Ubuntu official website to down...

Use Grafana+Prometheus to monitor MySQL service performance

Prometheus (also called Prometheus) official webs...

HTML embedded in WMP compatible with Chrome and IE detailed introduction

In fact, there are many corresponding writing met...

How to move a red rectangle with the mouse in Linux character terminal

Everything is a file! UNIX has already said it. E...

Linux system file sharing samba configuration tutorial

Table of contents Uninstall and install samba Cre...

React implements paging effect

This article shares the specific code for React t...

JavaScript to achieve the effect of clicking on the self-made menu

This article shares the specific code of JavaScri...

Analyze the difference between computed and watch in Vue

Table of contents 1. Introduction to computed 1.1...

Solution to MySQL connection exception and error 10061

MySQL is a relational database management system ...

Sample code for a simple seamless scrolling carousel implemented with native Js

There are many loopholes in the simple seamless s...