简体   繁体   English

在 MySQL 中创建简单数据库

[英]Creating Simple Database in MySQL

all, I'm new to using MySQL and I'm having some issues creating a simple database for uploading a basic ruby app.总而言之,我是使用 MySQL 的新手,我在创建用于上传基本 ruby 应用程序的简单数据库时遇到了一些问题。 Can anybody help me with the format to use in the MySQL Command?任何人都可以帮助我使用 MySQL 命令中的格式吗? I'm using MySQL 5.5.我正在使用 MySQL 5.5。

I have searched online;我在网上搜索过; however, all of the typical formats for creating a database seem to have no result at all on prompt - should I be seeing some sort of visual confirmation that a database was created?然而,所有用于创建数据库的典型格式似乎都没有任何结果——我是否应该看到某种视觉确认数据库已创建? Thanks, all!谢谢大家!

As a new user I would highly recommend trying out phpMyAdmin as an interface to MySQL.作为一个新用户,我强烈建议尝试将 phpMyAdmin 作为 MySQL 的接口。 I know it's not ruby, but if you have php setup already anyways it's a very useful tool.我知道它不是 ruby,但如果您已经安装了 php,无论如何它是一个非常有用的工具。

http://www.phpmyadmin.net/home_page/index.php http://www.phpmyadmin.net/home_page/index.php

With this tool, you can create a database with the click of a single button, run SQL commands, create tables and set permissions.使用此工具,您可以一键创建数据库、运行 SQL 命令、创建表和设置权限。

Try doing DESCRIBE tablename where tablename is the name of a table you think you have created.尝试做DESCRIBE tablename其中tablename是您认为您创建的表的名称。 That way you can check whether it was created or not.这样您就可以检查它是否已创建。

The command for creating a database is CREATE DATABASE database_name;创建数据库的命令是CREATE DATABASE database_name; . . Don't forget the semicolon at the end.不要忘记最后的分号。

If it's successful you should see a message like Query OK, 1 row affected (0.00 sec) .如果成功,您应该会看到类似Query OK, 1 row affected (0.00 sec)的消息。 Any query should have at east this much output.任何查询都应该有这么多的 output。 If you see no message at all (eg you press enter and the next line just looks like a -> prompt) make sure you've closed all of your parentheses and quotation mark and ended the query with a semicolon ( ; ).如果您根本看不到任何消息(例如,您按下回车键,下一行看起来像->提示符),请确保您已关闭所有括号和引号并以分号 ( ; ) 结束查询。

Yes, MySQL informs you of the result of each query.是的,MySQL 会通知您每个查询的结果。 Here's what I've just got:这是我刚刚得到的:

mysql> create database foo; mysql> 创建数据库 foo;

Query OK, 1 row affected (0.01 sec)查询正常,1 行受影响(0.01 秒)

mysql> use foo; mysql> 使用 foo;

Database changed数据库已更改

mysql> show tables; mysql> 显示表;

Empty set (0.00 sec)空集(0.00 秒)

mysql> mysql>

If you need visual feedback, please consider downloading MySQL Workbench - it is easy to use and, as a GUI application, is explicit enough to make a new user feel comfortable.如果您需要视觉反馈,请考虑下载MySQL Workbench - 它易于使用,并且作为一个 GUI 应用程序,其明确性足以让新用户感到舒适。

When you issue the following command at the mysql prompt:当您在 mysql 提示符处发出以下命令时:

CREATE database <database_name>;

You should be presented with the typical "Ok" prompt afterwards.之后,您应该会看到典型的“确定”提示。 You should then be able to do:然后,您应该能够:

show databases;

That will show you a list of databases on the system and in there you should see the database you created.这将向您显示系统上的数据库列表,您应该在其中看到您创建的数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM