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

mysql

时间:2015-06-06 22:00:56      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:


full-blown    成熟的
In a nutshell    简单地说
review        回顾,复习
grab        抓,攫取        这个词较难理解
go ahead    开始,前进
eavesdrop    窃听,偷听
vector        载体


How to manage remote MySQL databases on Linux VPS using a GUI tool
如何在一个linux VPS上使用一个GUI工具来远程管理MySQL数据库

If you need to run a MySQL server on a remote VPS instance, how will you manage databases hosted by the server remotely?
假如你需要在一个远程vps 实例上运行一个MySQL服务器,你将如何远程地管理由服务器托管的数据库。
Perhaps web-based database administration tools such as phpMyAdmin or Adminer will first come to mind.
或许基于web的数据库管理工具,如:phpMyAdmin或者Adminer会首先映入脑海。
These web-based management tools require a backend web server and PHP engine up and running.
这些基于web的管理工具需要一个后台web 服务器和PHP引擎启动并运行。
However, if your VPS instance is used as a standalone database server (e.g., for a multi-tier app), provisioning a whole LAMP stack for occasional database management is a waste of VPS resource.
然而,假如你的VPS实例被用作一个独立的数据库服务器(比如,一个多层app)为偶尔的数据库管理供应一个完整的LAMP堆栈,对VPS资源来说是一个浪费。
Worse, the LAMP stack with an additional HTTP port can be a source of security vulnerabilities of your VPS.
更坏的情况是,额外添加一个http端口的LAMP堆栈能成为你VPS的一个安全漏洞来源。


Alternatively, you can turn to a native MySQL client running on a client host.
或者,你可以转向一个运行在客户端主机上原生的MySQL客户端
Of course a pure command-line MySQL client (mysql-client) can be your default choice if nothing else.
当然一个纯命令行MySQL客户端会成为你的默认选择,如果没其它的话。
But the capabilities of the command-line client are limited, so it is not suitable for production-level database administration such as visual SQL development, performance tuning, schema validation, etc.
但是命令行客户端的功能是受限制的,因此它不适合生产库的管理,例如可视的SQL开发,性能调优,模式验证等。
If you are looking for full-blown MySQL administration features, a MySQL GUI tool will meet your requirements better.
假如你正寻找完全成熟的MySQL管理特性,一个MySQL GUI工具会更好地满足你的需要。



What is MySQL Workbench?
什么是MySQL Workbench?
Developed as an integrated database tool environment by Oracle, MySQL Workbench is more than a simple MySQL client.
由oracle开发为一个集成数据库工具,MySQL Workbench不只是一个简单的MySQL客户端。
In a nutshell, Workbench is a cross-platform (e.g., Linux, MacOS X, Windows) GUI tool for database design, development and administration.
简单地说,Workbench 是一个数据库设计,开发和管理的跨平台GUI工具。
The Community Edition of MySQL Workbench is available for free under the GPL.
社区版的MySQL Workbench在GPL下自由可用。
As a database administrator, you can use Workbench to configure MySQL server, manage MySQL users, perform database backup and recovery, and monitor database health, all in GUI-based user-frienly environment.
作为一个数据库管理员,你可以使用Workbench来配置MySQL服务器,管理MySQL用户,完成数据库备份与恢复,监控数据库健康,所有的这一切都在基于GUI的用户友好环境下。
In this tutorial, let‘s review how to install and use MySQL Workbench on Linux.
在这份指南中,让我们回顾一下如何在linux下安装使用MySQL Workbench。


Install MySQL Workbench on Linux
在linux下安装MySQL Workbench
To set up remote database administration environment, grab any desktop Linux machine where you will be running MySQL Workbench.
拿起任何你将运行MySQL Workbench的桌面linux机器来创建远程数据库管理环境。
While some Linux distributions (e.g., Debian/Ubuntu) carry MySQL Workbench in their repositories, it is a good idea to install it from the official repositories, as they offer the latest version.
一些linux发行版(例如,Debian/Ubuntu)在它们的库中搭载了MySQL Workbench,从官方库中安装它是一个好主意,因为它们提供最新版。
Here is how to set up the official Workbench repository and install Workbench from it.
这里是如何建立官方Workbench 库并从中安装它的方法。


Debian-based Desktop (Debian, Ubuntu, Mint):
Debian系桌面(Debian,Ubuntu,Mint):
Go to the official website. Download and install the DEB file for the repository. Choose one that matches with your environment.
到官方网站。从库中下载和安装DEB 文件。选择匹配你环境的一个文件。
For example, on Ubuntu 14.10:
例如,在Ubuntu 14.10上:

$ wget http://dev.mysql.com/get/mysql-apt-config_0.3.4-2ubuntu14.10_all.deb
$ sudo dpkg -i mysql-apt-config_0.3.4-2ubuntu14.10_all.deb

on Debian 7:
在Debian 7上:

$ wget http://dev.mysql.com/get/mysql-apt-config_0.3.3-1debian7_all.deb
$ sudo dpkg -i mysql-apt-config_0.3.3-1debian7_all.deb

When installing the DEB file, you will see the following package configuration menu, and be asked to choose MySQL product to configure.
安装DEB文件时,你将会看到下面的包配置菜单,并被询问配置选择MySQL产品。

Choose "Utilities". Once you are done with configuration, choose "Apply" to save it.
选择实用程序。一旦你配置完毕,选择应用来保存。
Finally, update package index, and install Workbench.
最后,更新包索引,并安装Workbench。

$ sudo apt-get update
$ sudo apt-get install mysql-workbench

Red Hat-based Desktop (CentOS, Fedora, RHEL):
红帽系桌面(CentOS,Fedora,RHEL):
Go to the official website. Download and install the RPM repository package for your Linux evironment.
到官方网站。下载安装适合你linux环境的rpm库包。
For example, on CentOS 7:
例如,在CentOS 7上:

$ wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
$ sudo yum localinstall mysql-community-release-el7-5.noarch.rpm

on Fedora 21:

$ wget http://dev.mysql.com/get/mysql-community-release-fc21-6.noarch.rpm
$ sudo yum localinstall mysql-community-release-fc21-6.noarch.rpm

Verify that "MySQL Tools Community" repository has been set up.
校验"MySQL 社区工具"库已经创建。
$ yum repolist enabled

Go ahead and install Workbench.
开始安装Workbench.
$ sudo yum install mysql-workbench-community


Set up a Secure Remote Database Connection
建立一个安全的远程数据库连接

The next step is to set up a remote connection to your MySQL server running on a VPS. Of course you can connect directly to the remote MySQL server from Workbench GUI (after enabling remote access in the database server).
下一步是创建一个到MySQL服务器的远程连接,MySQL服器运行在VPS之上。当然你可以从Workbench GUI中直接连接远程MySQL服务器(在数据库服务器启用远程访问后)。
However, it is a huge security risk to do so, as someone can easily eavesdrop on database access traffic, and a publicly-open MySQL port can be another attack vector.
然而,这么做是一个巨大的安全风险,因为有些人能简单窃听数据库访问流量,并且公开的MySQL端口也是另一种攻击的载体。

A better approach is to disable remote access of MySQL server (i.e., only allow access from 127.0.0.1 of a VPS).
一个更好的方法是禁用MySQL服务器的远程访问(也就是说,只允许从VPS的127.0.0.1访问)。

Then set up an SSH tunnel between a local client machine and a remote VPS, so that MySQL traffic can be securely relayed via their loopback interfaces.
在本地客户机器和一个远程VPS之间建立一个SSH 隧道,以便MySQL流量能安全地通过它们的本地回环接口转发。
Compared to setting up SSL-based encrypted connections, configuring SSH tunneling requires little effort as it only requires SSH server, which is already deployed on most VPS instances.
比较建立一个基于ssl的加密连接,配置ssh隧道需要更小的代价,因为它只需要SSH 服务器,而它已经在大多数的VPS实例上部署。
Let‘s see how we can set up an SSH tunnel for MySQL Workbench.
让我们看一下如何为MySQL Workbench来建立一个SSH隧道。
In this setup, you don‘t need to enable remote access of a MySQL server.
在这个设置中,你不需要启用MySQL服务器的远程访问。
On a local client host where MySQL Workbench will be running, type the following command. Replace ‘user‘ and ‘remote_vps‘ with your own info.
在运行MySQL Workbench的本地客户机上,输入如下命令,替换user和remote_vps为你自己的信息。
$ ssh user@remote_vps -L 3306:127.0.0.1:3306 -N

You will be asked to type an SSH password for your VPS. Once you successfully log in to the VPS, an SSH tunnel will be established between port 3306 of local host and port 3306 of a remote VPS. Note that you won‘t see any message in the foreground.
你将被询问输入一个VPS的SSH密码。一旦成功登入VPS,一个SSH隧道将在本地主机的3306端口和远程VPS的3306端口之间建立,注意在前台你将不会看到任何消息。
Optionally, you can set the SSH tunnel running in the background. For that, press Ctrl+Z to stop the command, type bg and press ENTER.
另外,你可以设置SSH隧道运行在后台。要那么做的话,按Ctrl+Z来停止命令。敲入bg并回车。
The SSH tunnel will now be running in the background.
SSH隧道现在运行在后台了。


Manage a Remote MySQL Server with MySQL Workbench
用MySQL Workbench 管理一个远程MySQL 服务器
With an SSH tunnel established, you are ready to connect to a remote MySQL server from MySQL Workbench.
伴随着SSH隧道的建立,你准备从MySQL Workbench来连接一个远程MySQL服务器。
Launch Workbench by typing:
敲入下面命令启动Workbench:
$ mysql-workbench

Click on the plus icon at the top of the Workbench screen to create a new database connection. Fill in connection information as follows.
在Workbench屏幕的顶端点击加号图标来创建一个新的数据库连接。填入如下的连接信息。
    Connection Name: any description (e.g., My remote VPS database)
    Hostname: 127.0.0.1
    Port: 3306
    Username: MySQL username (e.g., root)

Note that since the tunnel‘s local endpoint is 127.0.0.1:3306, the hostname field must be 127.0.0.1, not the IP address/hostname of a remote VPS.
注意因为隧道的本地端点是127.0.0.1:3306,所以主机名字段必须是127.0.0.1,而不是远程VPS的ip地址或主机名。
Once you set up a new database connection, you will see a new box for the connection appear on Workbench window. Click on the box to actually establish a connection to a remote MySQL server.
一旦你建立一个新的数据库连接,你将看到一个新的连接框出现在Workbench 窗口。点击方框来实际地建立一个到远程MySQL 服务器的连接。
Once you are logged in to the MySQL server, you will see various administrative tasks in the left-side panel. Let‘s review some of common administrative tasks.
一旦你登入MySQL服务器,你将在左侧面板看到多个管理任务。让我们查看一些普通的管理任务。

MySQL Server Status

This menus shows real-time dashboard of database server resource usage (e.g., traffic, connections, read/write).
这个菜单显示了数据库服务器资源使用的实时仪表盘(例如,流量,连接,读写)。
Client Connections

The total number of client connections is a critical resource to monitor. This menu shows detailed information of individual client connections.
客户连接总数是一个要监视的重要资源。这个菜单显示了独立客户连接的详细信息。

Users and Privileges

This menu allows you to manage MySQL users, including their resource limits and privileges.
这个菜单允许你管理MySQL 用户,包括它们的资源限制和权限。
MySQL Server Administration

You can start or stop a MySQL server, and examine its server logs.
你能开启或停止一个MySQL服务器,并检查它的日志。

Database Schema Management

You can view, change or inspect database schema visually. For that, choose and right-click on any database or table under "Schemas" heading.
你可以查看,更改或者可视化地检验数据库模式。要那么做的话,选择并右击任一数据库或者在模式头下的表。
Database Query

You can execute any arbitrary query (as long as your login privilege allows), and inspect its result.
你可以执行任意的查询(只要你的登录权限允许),并校验它的结果。
Note that performance statistics and reports are available for MySQL server 5.6 and higher. For 5.5 and lower, the performance section will be grayed out.
注意性能统计和报告只在MySQL 服务器5.6及更高才可用。5.5及以下,性能部分将变灰。

Conclusion
结论
The clean and intuitive tabbed interface, comprehensive feature sets, and open-source licensing make MySQL Workbench one of the best visual database design and administration tools out there.
干净和直观的标签式接口,综合特性集,和开源许可证使得MySQL Workbench成为最好的可视化数据库设计与管理工具之一。
One known downside of Workbench is its performance. I notice that Workbench sometimes gets sluggish while running queries on a busy server.
Workbench一个已知的缺点是它的性能。我注意到Workbench当在一个繁忙的服务器上运行查询时,有时变得缓慢。
Despite its less than stellar performance, I still consider MySQL Workbench an essential tool for any professional MySQL database administrator and designer.
尽管它的性能不是一流的,我依然认为MySQL Workbench对任何一个专业的MySQL数据库管理员和设计者来说都是一个专业工具。
Have you ever used Workbench in your work environment? Or do you recommend any other GUI tool? Feel free to share your experience.
在你的工作环境中还没有用过Workbench吗?或者你能推荐其它的GUI工具吗?随时分享你的经验。

mysql

标签:

原文地址:http://www.cnblogs.com/createyuan/p/4557268.html

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