如何注册一个mysql数据库? [英] How do I register an mysql database?

查看:23
本文介绍了如何注册一个mysql数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉问一个关于 MySQL 的菜鸟问题.我下载了 FlightStats 来了解 mysql,但我不知道如何用我的 localhost mysql db 注册它.我知道在 MS SQL 中,您可以使用 sql studio 简单地注册任何 sql 数据库.我试图谷歌,但没有结果.也许,我的搜索词是错误的.我正在搜索如何注册 mysql 数据库、注册 mysql 数据库...等".您如何从现有数据库(如 FlightStats)注册或设置数据库?我正在使用 DBVisualizer.dbVis 中是否有我不知道的注册数据库的方法?

Sorry for a noob question regarding MySQL. I downloaded FlightStats to learn about mysql but I can't figure out how to register it with my localhost mysql db. I know in MS SQL you can simply register any sql db using sql studio. I tried to google but come up with no result. Perhaps, my search phrase is wrong. I'm searching with "how to register a mysql database, register a mysql database...etc.". How do you register or setup an database from existing database like FlightStats? I'm using DBVisualizer. Is there a way in dbVis that I'm not aware of to regsiter a database?

谢谢

抱歉措辞不好.我找到了这个.我有 .myd、.myi 和 .frm,我想让它用我的本地 mysql 实例恢复(?).我查看了所有答案,但我仍然对如何从这 3 个文件中恢复数据库感到困惑.

edit: sorry for the bad wording. I found this. I have the .myd, .myi and .frm and I want to get it to restore(?) with my local mysql instance. I look at all the answers but I'm still confuse as how you restore the database from those 3 files.

推荐答案

先介绍一下背景.原始问题中链接的 FlightStats 下载页面似乎提供了来自 MySQL 数据目录的二进制表存储文件的压缩 tarball.鉴于这被认为是一种可行的分发方式,并结合 MERGE 表的使用,我推测此 tarball 包含一堆 MyISAM 数据文件(.myi.myd). Jack 的编辑证实了这种情况.

A little background first. The FlightStats download page linked to in the original question appears to provide zipped tarballs of the binary table storage files from the MySQL data directory. Given that this is considered a viable means of distribution, and combined with the use of MERGE tables, I would surmise that this tarball contains a bunch of MyISAM data files (.myi, .myd). Jack's edit confirms that this is the situation.

这是分发 MySQL 数据集的一种非典型方式,尽管在备份 MyISAM 存储时并不少见,而且在移动大型数据集时可能并非闻所未闻;它可能比相应的转储文件更节省空间.当然,在 SQL Server 领域,将数据库文件附加到实例中是很常见的.

This is an atypical means of distributing a MySQL data set, although not at all uncommon when backing up MyISAM storage, and probably not all that unheard of for moving large data sets around; it likely works out considerably more space-efficient than a corresponding dump file. Of course, in SQL Server land, it's pretty common to attach database files into an instance.

一般来说,您可以按如下方式恢复数据库:

Broadly speaking, you'd recover the database as follows:

  1. 定位到MySQL数据目录;通常 /var/mysql 或类似的
  2. 使用所需的数据库名称创建一个新目录,例如航班数据
  3. 将压缩包中的.myi.myd等文件解压到该目录下
  4. 确保整个目录由用户拥有 MySQL 运行方式(通常是 mysql) - 使用 chmod -R 确保你得到一切
  5. 打开一个 MySQL 控制台
  6. USE
  7. 显示表格
  1. Locate the MySQL data directory; typically /var/mysql or similar
  2. Create a new directory with the desired database name e.g. flightdata
  3. Extract the .myi, .myd and other files from the tarball into this directory
  4. Make sure the entire directory is owned by the user MySQL runs as (usually mysql) - use chmod -R to make sure you get everything
  5. Open a MySQL console
  6. USE <database-name>
  7. SHOW TABLES

您应该会看到列出的一些表格.此外,链接的下载页面包括几个 SQL 脚本,其中包含在数据库就位后需要对数据库运行的 SQL 命令.这些将导致重新构建合并定义和表索引.您可以将这些通过管道传输到命令行客户端,例如<代码>mysql -u<用户名>-p<密码><数据库名称><.

You should see some tables listed. In addition, the downloads page linked includes a couple of SQL scripts, which contain SQL commands that you need to run against your database once it's in place. These will cause the merge definitions and table indexes to be rebuilt. You can pipe these into the command-line client, e.g. mysql -u<username> -p<password> <database-name> < <sql-file>.

在执行此操作时关闭 MySQL 服务器可能是个好主意;使用例如/etc/init.d/mysql stop 或类似的,并在文件解压到位后重新启动.

It may be a good idea to shut down the MySQL server while you're doing this; use e.g. /etc/init.d/mysql stop or similar, and restart once the files are extracted in place.

这篇关于如何注册一个mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆