程序和mysql打包_带有打包应用程序MySQL管理

程序和mysql打包

Some years back, the Chrome team announced packaged apps – applications that behave like native ones, with access to a large part of your machine’s hardware. Ever since, we’ve seen terminal emulators, IRC clients, IDEs, true 3D games and more pop up.

几年前,Chrome团队宣布了打包的应用程序-行为类似于本机的应用程序,可以访问您计算机的大部分硬件。 从那时起,我们已经看到了终端模拟器,IRC客户端,IDE,真正的3D游戏以及更多的弹出窗口。

ChromeMyAdmin (ChromeMyAdmin)

I’d like to take this opportunity and review ChromeMyAdmin, a Packaged App by Yoichiro Tanaka.

我想借此机会回顾一下Yoichiro Tanaka的打包应用程序ChromeMyAdmin

I personally consider the MySQL/MariaDB database management landscape particularly barren. With the often unstable MySQL Workbench on one hand, and the bloated but underdeveloped PhpMyAdmin on the other, sometimes you just need a simpler solution for quick and dirty edits.

我个人认为MySQL / MariaDB数据库管理环境特别贫乏。 一方面通常是不稳定MySQL Workbench,另一方面是the肿但开发不完善的PhpMyAdmin,有时您只需要一个更简单的解决方案即可进行快速而肮脏的编辑。

Let’s take it for a spin and see how it does.

让我们旋转一下,看看它是如何工作的。

正在安装 (Installing)

Go to the Web Store page and install the app. It should appear in your Chrome App launcher immediately. On Windows, this looks like the figure below:

转到“ 网上商店”页面并安装该应用程序。 它应立即显示在您的Chrome应用启动器中。 在Windows上,如下图所示:

alt

The starting interface is simple and smooth, a familiar Bootstrap look:

启动界面简单流畅,具有熟悉的Bootstrap外观:

alt

无家可归 (Vagrant Up)

If you’ve read any of my previous posts, you know I don’t favor polluting my everyday machine with SDKs, programming languages and their runtimes, or database drivers. I’ve made a simple Vagrantfile which boots up a 14.04 Ubuntu server instance with MySQL pre-installed, and remote connections enabled. This means you can jack into the virtual machine’s database from the host machine and still keep your host machine clean of unwanted software.

如果您阅读过我以前的任何文章,您就会知道我不赞成使用SDK,编程语言及其运行时或数据库驱动程序来污染我的日常计算机。 我制作了一个简单的Vagrantfile,它启动了一个14.04 Ubuntu服务器实例,该实例已预安装MySQL,并启用了远程连接。 这意味着您可以从主机插入虚拟机的数据库,并且仍然使您的主机清除有害软件。

If you’re not familiar with Vagrant and the aforementioned virtualization methods, please see our previous articles on the topic.

如果您不熟悉Vagrant和上述虚拟化方法,请参阅我们以前关于该主题的文章

You can download the Vagrantfile from Github. After you do, simply bash into the folder (use Git Bash if on Windows) and run “vagrant up”, provided you have Vagrant and VirtualBox installed.

您可以从Github下载Vagrantfile。 完成后,只要安装了Vagrant和VirtualBox,只需将bash放入文件夹(如果在Windows上使用Git Bash)并运行“ vagrant up”。

连接中 (Connecting)

The IP address of our VM is set to 192.168.56.101, so this is what we use for the connection’s host name in ChromeMyAdmin’s main screen. This is also the first place ChromeMyAdmin dropped the ball – you have to input the port number – it doesn’t assume a default. Not a big problem, but it would get bonus points for usability.

我们的VM的IP地址设置为192.168.56.101,因此我们在ChromeMyAdmin的主屏幕中将其用作连接的主机名。 这也是ChromeMyAdmin丢球的第一站–您必须输入端口号–它不采用默认值。 这不是什么大问题,但是它会为可用性带来加分。

After we input the credentials (root, root, if you’re using my Vagrantfile), we should be able to successfully test the connection.

输入凭据(root,root,如果您使用的是Vagrantfile)后,我们应该能够成功测试连接。

alt

Immediately after hitting “Connect” (and possibly “Add to Favorites”), you should see the next screen allowing you to select a database.

点击“连接”(可能还有“添加到收藏夹”)后,您应该立即看到下一个屏幕,您可以选择一个数据库。

创建和填充数据库 (Creating and Populating a Database)

Let’s take it for a quick spin and create a new database. Click the little plus icon in the bottom right corner of the window to initialize the process. Make sure you’re on “server view”, to which you get by clicking the “hard drive” icon in the top left corner, next to the database selection dropdown. Leave the encoding option on the UTF-8 Unicode default and type in a sample name like “test”. You should then see your database in the database selection dropdown, from where you can select it.

让我们快速浏览一下并创建一个新的数据库。 单击窗口右下角的小加号图标以初始化该过程。 单击数据库选择下拉菜单旁边的左上角的“硬盘”图标,以确保进入“服务器视图”。 将编码选项保留为UTF-8 Unicode默认值,然后输入示例名称,例如“ test”。 然后,您应该在数据库选择下拉列表中看到您的数据库,从中可以选择它。

alt

We create a new table by clicking the little plus icon in the bottom left corner. Create a table called “users”, and leave all other options on their default values. You’ll notice ChromeMyAdmin automatically creates an unsigned integer field that autoincrements and makes it a primary key of the table. While this goes quite nicely in hand with my own habits, I’m certain some people will be bothered by this and the inability to change the default behavior. Such actions should definitely be configurable.

我们通过点击左下角的小加号图标创建一个新表。 创建一个名为“用户”的表,并将所有其他选项保留为其默认值。 您会注意到ChromeMyAdmin自动创建一个无符号整数字段,该字段会自动递增并使其成为表的主键。 尽管这与我的习惯非常相符,但我敢肯定,某些​​人会对此感到困扰,并且无法更改默认行为。 这样的动作绝对应该是可配置的。

Using the third plus button “Add new column” in the table column view frame, add the fields “first_name“, “last_name“, “username” and “password“. Make them all maximum varchars. I allowed NULL on first_name, but on no other field.

使用表列视图框架中的第三个加号按钮“添加新列”,添加字段“ first_name ”,“ last_name ”,“ username ”和“ password ”。 使它们全部为最大varchars。 我在first_name上允许NULL,但在其他字段上不允许。

We need to make our username field unique now, in order to make sure no two of our users have overlapping usernames. Let’s do this by adding an index with the plus icon which previously served as the “Create Database” button – the bottom right plus in the app’s window. Use the settings I used in the figure below.

现在,我们需要使用username字段唯一,以确保没有两个用户具有重叠的用户名。 为此,我们添加一个带有加号图标的索引,该图标以前用作“创建数据库”按钮-应用程序窗口的右下角加号。 使用我在下图中使用的设置。

alt

Don’t forget to click the “Add” button next to the selected column first, otherwise the Add button in the bottom row of the modal window will never activate.

不要忘了先单击所选列旁边的“添加”按钮,否则,模态窗口底部一行的“添加”按钮将永远不会激活。

If, at any point, you’re curious about the SQL statements that get executed as you click around the interface, go into the Configure menu (top right, in between “Query” and the power off icon) , and select Query History.

如果您随时对在界面上单击时执行SQL语句感到好奇,请进入“配置”菜单(右上角,在“查询”和电源关闭图标之间),然后选择“查询历史记录”。

We now have a table with some columns and indices defined – let’s use the Query window to create two more tables: users_groups and user_groups. In the Query window (top right option, between Structure and Configure), paste the following:

现在,我们有了一个定义了一些列和索引的表-让我们使用“查询”窗口创建另外两个表: users_groupsuser_groups 。 在“查询”窗口中(“右上角”选项,在“结构”和“配置”之间),粘贴以下内容:

CREATE TABLE `user_groups` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(120) NOT NULL,
  `slug` varchar(120) NOT NULL,
  `description` text,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email_address_UNIQUE` (`name`),
  UNIQUE KEY `slug_UNIQUE` (`slug`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `test`.`users_groups` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `users_id` INT UNSIGNED NOT NULL,
  `groups_id` INT UNSIGNED NOT NULL,
  `main` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `user_group_unique` (`users_id` ASC, `groups_id` ASC),
  INDEX `users_groups_user_groups_id_idx` (`groups_id` ASC),
  CONSTRAINT `users_groups_users_id`
    FOREIGN KEY (`users_id`)
    REFERENCES `test`.`users` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `users_groups_user_groups_id`
    FOREIGN KEY (`groups_id`)
    REFERENCES `test`.`user_groups` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE);

At first, I was disappointed to find ChromeMyAdmin lacking an SQL import tool, but I was even more disappointed when I realized that it is unable to execute two statements one after the other. No matter – pasting in one CREATE, executing, then doing the same for other worked and we now have all three tables.

起初,我很失望地发现ChromeMyAdmin缺少SQL导入工具,但是当我意识到它无法依次执行两个语句时,我感到更加失望。 没关系–粘贴一个CREATE,执行,然后对其他工作进行相同的操作,现在我们有了所有三个表。

The CREATE statement also created the necessary indices and some foreign keys that bind the three tables together in an M:M fashion. But… where are our foreign keys?

CREATE语句还创建了必要的索引一些外键,以M:M方式将三个表绑定在一起。 但是...我们的外键在哪里?

alt

ChromeMyAdmin does NOT support GUI editing of foreign keys in its current iteration. Still under heavy development and by only one person, advanced features such as those are, unfortunately, being put on the backburner.

ChromeMyAdmin在当前迭代中不支持外键的GUI编辑。 不幸的是,诸如此类的高级功能仍在繁重的开发工作中,仅由一个人完成。

Ok, let’s see what else we can do.

好吧,让我们看看我们还能做什么。

Open the user_groups table and add two groups: admin and user. You do this by selecting the table, then selecting “rows” in the top navigation, and finally hitting the bottom-right plus icon. In its current form, ChromeMyAdmin offers a regular textarea for every column data type, and does not prepopulate values in any way, not even with default values. We can, however, leave the field we know is set to autoincrement empty, and ChromeMyAdmin and MySQL will take care of the rest for us.

打开user_groups表并添加两个组:admin和user。 为此,您可以选择表格,然后在顶部导航中选择“行”,最后点击右下角的加号图标。 在当前形式下,ChromeMyAdmin为每种列数据类型提供常规的textarea,并且不会以任何方式预填充值,即使使用默认值也是如此。 但是,我们可以将我们知道的字段设置为autoincrement保留为空,ChromeMyAdmin和MySQL将为我们处理其余的工作。

alt

The autoincrement works well, and we add two rows:

自动增量效果很好,我们添加了两行:

alt

Let’s add two users now. Name them whatever you wish, but try giving the second one the same username as the first. We can see the error reporting works well, and we’re prevented from adding the second user unless we change the username.

现在添加两个用户。 随便给它们命名,但尝试给第二个提供相同的用户名。 我们可以看到错误报告的效果很好,除非更改用户名,否则我们将无法添加第二个用户。

alt

However, the autoincrement still triggered, and our second user now has an ID of 3 instead of 2.

但是,自动增量仍然会触发,并且我们的第二个用户现在的ID为3而不是2。

alt

Granted, this is a MySQL issue, but it can easily be avoided if proper measures are taken.

当然,这是一个MySQL问题,但是如果采取适当的措施,可以很容易避免

Finally, let’s add some users_groups entries. In modern MySQL management tools, adding a new row into a table that has a foreign key bound to its columns would turn the input fields into dropdown menus from which you can select the correct value. In ChromeMyAdmin, the GUI looks identical to the one where you add rows into a table without foreign keys – pure textareas.

最后,让我们添加一些users_groups条目。 在现代MySQL管理工具中,在表中添加新行,并在表中绑定外键,这会将输入字段变为下拉菜单,您可以从中选择正确的值。 在ChromeMyAdmin中,GUI看起来与将表添加行而不使用外键(纯文本区域)的GUI相同。

If you try to add the entry NULL, 5, 5, 0, you’re successfully stopped. After all, there are no users or groups with the ID = 5. Let’s add three valid entries instead:

如果尝试添加条目NULL, 5, 5, 0 ,则您已成功停止。 毕竟,没有ID = 5的用户或组。让我们添加三个有效条目:

NULL, 1, 1, 1 NULL, 1, 2, 0 NULL, 3, 2, 1

NULL, 1, 1, 1 NULL, 1, 2, 0 NULL, 3, 2, 1

The first one sets the first user as the admin, and defines admin as his main role. The second one also gives him a “user” role, just because every user of the website should have it. The third entry gives the second user the main role of “user”.

第一个将第一个用户设置为admin,并将admin定义为其主要角色。 第二个也给他一个“用户”角色,只是因为网站的每个用户都应该拥有它。 第三个条目为第二个用户提供了“用户”的主要角色。

With these roles defined, let’s see how ChromeMyAdmin handles deletions of values that are bound by foreign keys and set to Cascade (as the Create statement above defined them).

定义好这些角色后,让我们看看ChromeMyAdmin如何处理由外键绑定并设置为Cascade的值的删除(正如上面的Create语句定义了它们)。

alt

As you can see, the situation resolves perfectly. The logic behind this is up to MySQL, but it’s very important to see that ChromeMyAdmin not only sends the proper commands, but also refreshes all that needs refreshing.

如您所见,情况可以完美解决。 其背后的逻辑取决于MySQL,但非常重要的一点是要确保ChromeMyAdmin不仅发送正确的命令,而且还刷新所有需要刷新的内容。

In this current version, this is the extent of ChromeMyAdmin – very basic operations on your databases, limited query history, and some elemental constraints which can be realized only through manual input via the Query frame.

在当前版本中,这就是ChromeMyAdmin的范围–对数据库的非常基本的操作,有限的查询历史记录以及某些元素约束,这些约束只能通过通过查询框架手动输入才能实现。

贡献 (Contributing)

You can find the full source code of ChromeMyAdmin on Github and the JS MySQL Driver that powers it alongside it. Both projects accept contributions and could use your help. Yoichiro will be looking at your PRs and approving them on a case by case basis, or you can just fork it and make your own version.

你可以找到ChromeMyAdmin的全部源代码在Github和JS MySQL驱动程序是它的权力在它旁边 。 这两个项目都接受捐款,可以使用您的帮助。 Yoichiro将查看您的PR,并逐案批准它们,也可以分叉并制作自己的版本。

If you do decide to upgrade it, do document the procedure and let us know, we’d love more contribution examples.

如果您决定升级它,请记录一下过程,并告诉我们,我们将为您提供更多的贡献示例

结论 (Conclusion)

What’s the final tally? Is ChromeMyAdmin worth it? Let’s look at the pros and cons.

最后的提示是什么? ChromeMyAdmin是否值得? 让我们看一下利弊。

优点 (Pros)

  • automatically installs on every Chrome instance you log into, and is ready to go

    自动在您登录的每个Chrome实例上安装,并准备就绪
  • fast, in spite of using Bootstrap for the GUI

    尽管将Bootstrap用于GUI,但是速度很快
  • open source, can be easily extended and upgraded

    开源,可以轻松扩展和升级

缺点 (Cons)

  • automatically installs, but doesn’t transfer saved connections. Some may be remote and tedious to re-add.

    自动安装,但不传输已保存的连接。 重新添加可能有些偏僻且乏味。
  • no SSL or other advanced connection options – only the very basic types of connecting supported. This is good when you’re doing local development, but probably renders it quite useless when doing production database inspection or maintenance. Then again, would you use anything other than a behemoth app like Workbench for that?

    没有SSL或其他高级连接选项-仅支持非常基本的连接类型。 在进行本地开发时,这很好,但是在进行生产数据库检查或维护时,可能会使它变得毫无用处。 再说一次,您是否会使用诸如Workbench之类的庞然大物应用程序以外的其他功能?
  • no foreign keys

    没有外键
  • cannot select multiple entries for multi-delete (drop several tables at once, drop several rows at once)

    无法为多次删除选择多个条目(一次删除多个表,一次删除几行)
  • cannot deactivate foreign key check on deletion (very important when dropping data with foreign keys, especially during development when you need to reiterate quickly)

    无法删除时停用外键检查(在删除带有外键的数据时,尤其是在需要快速重申的开发过程中,这一点非常重要)
  • cannot execute several statements at once

    无法一次执行多个语句

All in all, ChromeMyAdmin is a decent tool for basic database management. It will install automatically for you, allow you to perform basic operations, and that’s all you really need when doing small tasks or demos and don’t feel like installing Workbench, PhpMyAdmin, SequelPro or another more fully-fledged app. In time, I hope to see it drastically evolve into something that can rival the best of them out there right now, but until then, I intend to use it for simple tasks and keep an eye on it.

总而言之,ChromeMyAdmin是用于基本数据库管理的不错的工具。 它会自动为您安装,允许您执行基本操作,这是您执行小任务或演示时真正需要的,并且不想安装Workbench,PhpMyAdmin,SequelPro或其他功能更完善的应用程序。 随着时间的流逝,我希望看到它能Swift发展成可以与目前最好的产品相媲美的东西,但是在那之前,我打算将其用于简单的任务并密切关注它。

Have you tried it out? Would you replace your current MySQL tool with it? Let us know in the comments below.

你试过了吗? 您会用它替换当前MySQL工具吗? 在下面的评论中让我们知道。

翻译自: https://www.sitepoint.com/mysql-management-packaged-apps/

程序和mysql打包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值