's Blog

Look at the sky, it's so beautiful

Connect to MySQL on Ubuntu VM

| Comments

Step 1: Comment out bind-address on /etc/mysql/my.conf or change it to your VM ip address.

1
#bind-address = 127.0.0.1

Step 2: Create a MySQL user with full/part privileges on all database:

1
2
3
4
5
create user 'username'@'localhost' identified by 'password';
grant all privileges on *.* to 'username'@'localhost' with grant option;

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

Step 3: Open your Ubuntu VM, goto Setting->Network->Adapter1 tab->Port Forwarding, add rule: name:mysql protocol:tcp host ip: [blank] host port: 3306 guest ip: [blank] guest port: 3306

click ok

step 4: Connect MySQL in your host machine,

1
2
3
c:>mysql -uusername -ppassword
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

Comments