Azure云中已经创建了Azure Database for MySQL服务
需要通过虚拟机Virtual machines连接Azure Database for MySQL数据库
1. 安装MySQL客户端在Virtual machines中
首先:MySQL有两种服务:MySQL的服务端和 MySQL的客户端。无论是Windows是还是Linux都是有服务端和客户端之分的。我们平时传统的“mysql -uroot -p”其实是使用的MySQL的客户端(MySQL)直连MySQL的服务端(mysqld)的。
由于Azure中直接配置的Azure Database for MySQL服务,我们不需要再安装MySQL,如果通过Internal方式连接,只需要在VM中安装MySQL客户端即可:
# yum install mysql
注意:通过yum方式安装MySQL时候,yum -y install mysql mysql-server mysql-devel
其中的mysql
就是MySQL客户端的意思,mysql-server
是MySQL的服务端,mysql-devel
是MySQL的开发端。
安装过程可能出现的信息示例:
Loaded plugins: downloadonly, fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirror.wiredtree.com
* extras: mirrors.serveraxis.net
* updates: bay.uchicago.edu
Setting up Install Process
Resolving Dependencies
--> Running transaction check
--> Package mysql.x86_64 0:5.1.71-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mysql x86_64 5.1.71-1.el6 base 893 k
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 893 k
Installed size: 2.4 M
Is this ok [**y/N**]: y
Downloading Packages:
mysql-5.1.71-1.el6.x86_64.rpm | 893 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mysql-5.1.71-1.el6.x86_64 1/1
Verifying : mysql-5.1.71-1.el6.x86_64 1/1
Installed:
mysql.x86_64 0:5.1.71-1.el6
Complete!
2. 连接到Azure Database for MySQL中
mysql -u USER-NAME-HERE -h MYSQL-DB-SERVER-IP-ADDRESS-HERE -p DB-NAME
mysql -h 10.20.30.40 -u username@hostname -p ******