How do I remotely access a MySQL server within a virtual machine from a local?

Source: Internet
Author: User
Tags mysql client

Assuming that the operating system is reinstalled, many local software may need to be re-installed, such as a database. However, assuming that we have some important software installed in the virtual machine, the database server can be backed up with the virtual machine before reinstalling the operating system. Once the operating system has been re-installed, the original database can still be used without any impact. However, assuming that the database is placed in the virtual machine, and our code development is generally on the actual Windows operating system, so there is a remote access to the database problem needs to be resolved.

Suppose you have a MySQL client installed on your local Windows system, you have MySQL server installed in the virtual machine unbunt, and now you want to access the MySQL servers inside the virtual machine from Windows clients.

Cmd

Mysql-h 192.168.9.9-u Root-p

ENTER PASSWORD:

The host IP address above is obtained by command ifconfig in Ubuntu.

However, by default, you do not have permission to access and you need to set up access permissions.

1, Cd/etc/mysql

2. Vim MY.CNF

3. Note the following line

4. Authorized users can connect remotely

Log on to the server side of the MySQL server, authorizing the root user to log on to the server from any host using password 123456.

GRANT all privileges on * * to ' myuser ' @ ' percent ' identified by ' 123456 ' with GRANT OPTION;

FLUSH Privileges

5. Restart the database

6. Execute on the Windows command line:

Mysql-h 192.168.9.9-u Root-p

SUCCESS

How do I remotely access a MySQL server within a virtual machine from a local?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.