Reputation: 1875
so I have a cpanel hosted database. My instructors have given us a script to load the IMDB database into our database. The file is a .sql file and it looks like this...
CREATE DATABASE IF NOT EXISTS `imdb` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `imdb`;
-- MySQL dump 10.13 Distrib 5.6.11, for Win32 (x86)
--
-- Host: localhost Database: imdb
-- ------------------------------------------------------
-- Server version 5.6.13-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `actors`
--
DROP TABLE IF EXISTS `actors`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `actors` (
`actorid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(250) NOT NULL,
`sex` enum('M','F') DEFAULT NULL,
PRIMARY KEY (`actorid`),
KEY `name` (`name`(10))
) ENGINE=InnoDB AUTO_INCREMENT=2798731 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `actors`
--
LOCK TABLES `actors` WRITE;
/*!40000 ALTER TABLE `actors` DISABLE KEYS */;
INSERT INTO `actors` VALUES (1378,'Abagnale Jr., Frank','M'),(1837,'Abbasi, Riz','M')
etc..
So I go to import the .sql file on cpanel..
And i'm getting an error
I'm not really sure how to go about doing this. The instructions are very vague and no office hours...
Appreciate the help.
Upvotes: 1
Views: 3522
Reputation: 456
The issue with this database import is that the following line states the database that you are importing data into. It is currently set to imdb.
CREATE DATABASE IF NOT EXISTS `imdb`
In cPanel mysql databases (with database prefixing enabled) will have your username prefixed to the beginning of the database name and the user supplied database name is postfixed. In this case you can look at the top of PhpMyAdmin and see:
Database: gress2_hw2
This means you will need to update your SQL and replace imdb to gress2_hw2for the data to be imported into the database you are currently in like in the example below:
CREATE DATABASE IF NOT EXISTS `gress2_hw2`
Additionally if you remove this line the mysql server will import the data into the database currently selected by PhpMyAdmin.
Upvotes: 1
Reputation: 1875
I had to change to change the script to
CREATE DATABASE IF NOT EXISTS `gress2_hw2` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `gress2_hw2`;
Since that what i had originally named my database.
Upvotes: 0