mysql安装后,默认情况下,远程连接是关闭的。
现在打开远程连接,步骤如下:
环境介绍如下:
宿主机是ubuntu,mysql安装在ubuntu里面了,安装了一个virtual-box,在里面装了一个window7虚拟机,现在想从windows里面连接ubuntu的mysql。
1、登陆ubuntu的mysql,执行以下命令:
2、执行之后,立即刷新权限,命令如下:
3、选择mysql数据库,执行以下命令:
可以看见包含以下输出:
4、编辑/etc/mysql/my.cnf,注释bind 127.0.0.1
5、重启mysql
6、windows连接mysql
[img]http://dl2.iteye.com/upload/attachment/0109/9276/f85afbe2-230d-3327-be90-132ce5b574b8.png[/img]
现在打开远程连接,步骤如下:
环境介绍如下:
宿主机是ubuntu,mysql安装在ubuntu里面了,安装了一个virtual-box,在里面装了一个window7虚拟机,现在想从windows里面连接ubuntu的mysql。
1、登陆ubuntu的mysql,执行以下命令:
grant all privileges on *.* to yangjianzhou@192.168.1.104 identified by "123456";
2、执行之后,立即刷新权限,命令如下:
flush privileges;
3、选择mysql数据库,执行以下命令:
select * from user \G;
可以看见包含以下输出:
Host: 192.168.1.104
User: yangjianzhou
Password: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: N
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin:
authentication_string: NULL
4、编辑/etc/mysql/my.cnf,注释bind 127.0.0.1
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
#
# * Fine Tuning
#
5、重启mysql
sudo /etc/init.d/mysql restart
* Stopping MySQL database server mysqld [ OK ]
* Starting MySQL database server mysqld [ OK ]
* Checking for tables which need an upgrade, are corrupt or were
not closed cleanly.
6、windows连接mysql
[img]http://dl2.iteye.com/upload/attachment/0109/9276/f85afbe2-230d-3327-be90-132ce5b574b8.png[/img]