简体   繁体   English

通过虚拟机连接MYSQL

[英]Connect To MYSQL Through Virtual Machine

I have windows and am running ubuntu 16.4 on a virtual machine for my analysis, I have installed and created user login and password to mysql databank through VM using this instruction:我有 windows 并在虚拟机上运行 ubuntu 16.4 以供我分析,我已经安装并创建了 mysql 数据库的用户登录名和密码,使用此指令:

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04 https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04

but now I don't understand how I can connect to it with my windows browser?但现在我不明白如何使用我的 windows 浏览器连接到它? Is it even possible to connect to mysql from my windows because technically I have installed it on another system (VM Ubuntu 16.4)?甚至可以从我的 windows 连接到 mysql,因为从技术上讲,我已经将它安装在另一个系统上(VM Ubuntu 16.4)?

I would appreciate if someone could guide me since I am a beginner.如果有人可以指导我,我将不胜感激,因为我是初学者。 thanks谢谢

You don't connect to a database server like MySQL using a browser, but rather with a dedicated client program.您不使用浏览器连接到像 MySQL 这样的数据库服务器,而是使用专用的客户端程序。

Some installations of MySQL also have a web program running called phpmyadmin. MySQL 的一些安装也有一个 web 程序正在运行,称为 phpmyadmin。 You can use that web program from your browser to do things to your MySQL server.您可以使用浏览器中的 web 程序对 MySQL 服务器执行操作。 But the digital ocean tutorial you followed doesn't install that.但是您遵循的数字海洋教程并没有安装它。

You need a MySQL client program running on your Windows machine to connect to the MySQL server on your VM.您需要在 Windows 机器上运行的 MySQL 客户端程序连接到 VM 上的 MySQL 服务器。 Ansgar Becker's HeidiSQL is a good choice. Ansgar Becker 的HeidiSQL是一个不错的选择。 So is MySQL Workbench from the MySQL team. MySQL 团队的MySQL Workbench也是如此。

And, be sure you can ssh from your Windows machine to your VM before you try all this stuff.而且,在你尝试所有这些东西之前,请确保你可以从你的 Windows 机器到你的 VM 的 ssh。 You'll need to know the IP address of your VM when you connect to your MySQL server from your MySQL client.从 MySQL 客户端连接到 MySQL 服务器时,您需要知道 VM 的 IP 地址。

Let's say your Windows machine has IP 192.0.2.101 and your VM has IP 192.0.2.121 .假设您的 Windows 机器具有 IP 192.0.2.101而您的 VM 具有 IP 192.0.2.121 You need to follow the steps in this part of your tutorial to create a MySQL user profile that can connect from your Windows machine.您需要按照教程这一部分中的步骤创建一个 MySQL 用户配置文件,该配置文件可以从您的 Windows 机器连接。 Something like this.像这样的东西。

CREATE USER 'xyz0o'@'192.0.2.101' IDENTIFIED BY 'someHardToGuessPassword';
FLUSH PRIVILEGES;

To create that user you need to ssh into your vm and run the mysql command line program.要创建该用户,您需要将 ssh 放入您的 vm 并运行mysql命令行程序。

Then from your client on your Windows machine you'll connect to the MySQL server on 192.0.2.121 using whatever username / password combination you gave in the CREATE USER command.然后从您的 Windows 机器上的客户端使用您在CREATE USER命令中提供的任何用户名/密码组合连接到192.0.2.121上的 MySQL 服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM