Mysql remote access to the database of problem solving

Keywords: cmd remote access mysql database 


Although there navicat graphical interface, but I still want to practice dos sql syntax.

First, let's introduce cmd command to access the database remotely, that fucked me for a long time, I began to have access method using connect MySQL client, showing no authority, in a seniors told me that the database is privileged, I bid farewell to the pit.

To execute mysql command, we must first find the location of mysql.exe file is located, here we must note that we are looking for is mysql.exe path, rather than mysql data file storage location.

Because the online method, there are two problems, confusing.

  1. mysql data file storage location, which is the storage location of the database and table we created in the local, specific methods are:show global variables like "%datadir%";(ps:可以先忽略这个"%datadir%",在后面用通配符查找字符串会知道。)结果为C:\ProgramData\MySQL\MySQL Server 8.0\Data\
  2. Here is what we need to do, I first opened the mysql client command-line interface , input method found by the search, Show the Variables like "% char%"; here is not to find the executable file mysql.exe, so I try to return a directory, and finally found it.

Here is a detailed explanation of the subfolders of the folder of the installation, ( but I feel no need to, you can find it, why installation directory hell of it, we want to know is: because we use the mysql command, so we switched to the mysql directory, so that it can perform mysql.exe.

C: \ Program Files \ MySQL \ MySQL Server 8.0 \ bin location is what I was looking for mysql.exe

                      (Cmd interface)

Then we enter:

  1. -h170.115.1.0 -uroot--p MySQL ( there is no semicolon, do not enter the first password , h represents a host address or IP address, u is the username, p is password password)
  2. When prompted, enter the password: If 123456

Interface will show us a successful login.

Here we will be able to practice or work mysq friends!


Guess you like