码迷,mamicode.com
首页 > 数据库 > 详细

使用windows-SQLyog连接linux-mysql

时间:2015-03-17 11:51:58      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:

      嘿嘿,最近又清闲了一点,重新安装了mysql去学习。  

-----博客园-邦邦酱好

 

系统环境:

1. 主机为windows系统,安装了SQLyog。

2. 主机上还安装了虚拟机,系统为centos6.4,里面安装了mysql5.0.95。

 

连接步骤:

1. 打开虚拟机的centos系统,登陆mysql,以启动mysql服务。

登陆方法大概如下:

[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.95-log Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type help; or \h for help. Type \c to clear the current input statement.

mysql> 

印象中可以设定某些文件,让它每天定时自启动的,没仔细了解,就不细说了。

 

2. 检查数据库“mysql”的“user”表,看看root对应的host是否设置正确。

mysql> use mysql
Database changed
mysql> select user,password,host from user;
+---------+-------------------------------------------+------+
| user    | password                                  | host |
+---------+-------------------------------------------+------+
| root    | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 | %    | 
| tester1 | 123                                       | %    | 
+---------+-------------------------------------------+------+
2 rows in set (0.00 sec)

mysql> 

注意:

(1)上文中root的host已经是%,意思是所有不同主机都可以连接到此处的mysql来,记得设置过表内容后,再接着在update语句下输入:mysql> FLUSH PRIVILEGES命令来更新表内容,否则SQLyog是感受不到数据库的改变的。

(2)其实%是不大安全的,理论上可以把host设置为主机win7系统的IP地址,这样就只有本机可以连接它了,但是我试了,发现不能连上,提示如下,我也搞不懂了。

                          技术分享

(3)host在这里不能被设为localhost,因为主机的IP地址和虚拟机中系统的IP地址是不一样的。可以使用ifconfig命令查看centos系统的IP地址,这里的我centos系统IP地址为:192.168.254.129。

[root@localhost ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:FE:DE:02  
          inet addr:192.168.254.129  Bcast:192.168.254.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fefe:de02/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:21330 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12326 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:28364229 (27.0 MiB)  TX bytes:757142 (739.3 KiB)
          Interrupt:19 Base address:0x2024 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:720 (720.0 b)  TX bytes:720 (720.0 b)

(4)如果把host设为localhost,那是因为mysql跟SQLyog是在同一个系统上安装的,所以才行。

 

3. 在SQLyog里新建一个连接

技术分享

注意:

(1)Saved Connects是你设定的连接名称,可以随意设定。

(2)MySQL Host Address是要连接的mysql所在的IP地址,如果mysql跟SQLyog安装在同一个系统上,那就可以写为:localhost。

(3)输入登录mysql所用的用户名,密码。

(4)其他信息默认即可。

 

4. 点击连接connect,如果成功,即可看到如下数据库结构:

技术分享

左右对比可见连接后看到的数据库名称,跟服务器上的数据库名称是一样的~~~

 

使用windows-SQLyog连接linux-mysql

标签:

原文地址:http://www.cnblogs.com/bangbangjiang/p/4343677.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!