错误 SQL查询:

--
-- Database: `work`
--
-- --------------------------------------------------------
--
-- Table structure for table `administrators`
--
CREATE TABLE IF NOT EXISTS `administrators` (

`user_id` varchar( 30 ) NOT NULL ,
`password` varchar( 30 ) NOT NULL ) ENGINE = InnoDB DEFAULT CHARSET = latin1;

MySQL说:

#1046 - No database selected

这里需要帮助。


当前回答

为了增加安全性,当在同一个脚本中使用多个DB时,您可以在查询中指定DB。创建表my_awesome_db.really_cool_table…

其他回答

引用伊万的话: 如果导入数据库,需要先创建一个同名的数据库,然后选择它,然后将现有的数据库导入到它。 希望它对你有用!”

以下是步骤: 创建一个数据库,例如my_db1, utf8_general_ci。 然后单击进入该数据库。 然后点击“导入”,选择数据库:my_db1.sql

应该就这些了。

你需要告诉MySQL使用哪个数据库:

USE database_name;

在创建表之前。

如果数据库不存在,您需要将其创建为:

CREATE DATABASE database_name;

紧随其后的是:

USE database_name;

首先选择数据库:使用db_name

然后创建表:CREATE table tb_name ( id int, 名字varchar (255), 工资int, 城市varchar (255) );

这是mysql 5.5版本语法

在mysql中新建一个数据库。选择新的DB。(如果你现在使用mysql phpmyadmin在顶部,它会像'服务器:…* >>数据库)。现在进入导入选项卡选择文件。导入!

如果你通过phpMyAdmin这样做:

I'm assuming you already Created a new MySQL Database on Live Site (by live site I mean the company your hosting with (in my case Bluehost)). Go to phpMyAdmin on live site - log in to the database you just created. Now IMPORTANT! Before clicking the "import" option on the top bar, select your database on the left side of the page (grey bar, on the top has PHP Myadmin written, below it two options:information_schema and name of database you just logged into. once you click the database you just created/logged into it will show you that database and then click the import option.

这招对我很管用。希望能有所帮助