将数据库导入 WAMP 服务器

Importing database into WAMP Server

我有一个朋友发给我的项目,我在将数据库导入我的 WAMP 服务器时遇到了严重的问题。我最终得到 Mysql 错误

错误

SQL查询:

--
-- Database: `drivers_endorsements`
--

-- --------------------------------------------------------

--
-- Table structure for table `admin`
--

CREATE TABLE IF NOT EXISTS `admin` (
`admin_id` int(11) NOT NULL,
  `username` varchar(30) NOT NULL,
  `password` varchar(12) NOT NULL,
  `name` varchar(40) NOT NULL
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3

MySQL said: Documentation #1046 - No database selected

首先您必须手动创建数据库或 select phpmyadmin 中的现有数据库(如前所述,使用 WAMP 服务器),然后导入 .sql 文件,并且数据库名称应与应用程序中使用的名称相同,否则将无法与数据库链接到的所需应用程序一起使用。

It's not really a big deal! The message itself is self-explanatory. You need to select an existing database first & then try your import.
Or you could possibly add the following at the very top of your DB script that you trying to import -

CREATE DATABASE IF NOT EXISTS drivers_endorsements; 
USE drivers_endorsements;