Windows 远程连接虚拟机(ubuntu)中Mysql 数据库

修改数据库为远程可登陆:

编辑文件:

sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf

找到下面这一行,加上#注释掉这一行:

#bind-address    = 127.0.0.1

 登陆mysql,然后授权,刷新:

sudo vim /etc/mysql/debian.cnf        #拿到debian-sys-maint 的密码

mysql -u debian-sys-maint -p        #登陆mysql

#设置root的密码
update mysql.user set authentication_string=password('你的密码') where user='root'

sudo service mysql restart        #重启服务

mysql -u root -p    #可用root账号登陆

grant all privileges on *.* to 'root'@'%' identified by '你的密码' with grant option;

flush privileges;

quit;

sudo service mysql restart  #重启服务

  

 然后用远程连接工具,连接mysql成功:

 
原文地址:https://www.cnblogs.com/gnq00/p/14673255.html