How to convert MySQL dump to SQL Server format - mysql

I have downloaded a SQL dump of wikimedia
It has below information
I do not want to install any MySQL server and just want to convert this code so that I can import to SQL Server 2019
-- MySQL dump 10.16 Distrib 10.1.38-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: 10.64.32.116 Database: enwiktionary
-- ------------------------------------------------------
-- Server version 10.1.43-MariaDB
/*!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 utf8mb4 */;
/*!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 `category`
--
DROP TABLE IF EXISTS `category`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `category` (
`cat_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`cat_title` varbinary(255) NOT NULL DEFAULT '',
`cat_pages` int(11) NOT NULL DEFAULT '0',
`cat_subcats` int(11) NOT NULL DEFAULT '0',
`cat_files` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`cat_id`),
UNIQUE KEY `cat_title` (`cat_title`),
KEY `cat_pages` (`cat_pages`)
) ENGINE=InnoDB AUTO_INCREMENT=50325885 DEFAULT CHARSET=binary ROW_FORMAT=COMPRESSED;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `category`
--
/*!40000 ALTER TABLE `category` DISABLE KEYS */;
INSERT INTO `category` VALUES (1,'Italian_verb_forms',318746,3,0),(3,'English_adjectives',131200,8,0),(4,'Mycology',101,101,0),(5,'English_verbs',41925,23,0),(7,'English_nouns',338181,19,0),(11,'Candidates_for_speedy_deletion',10,2,0),(13,'Translation_requests_(Hungarian)',0,0,0),(14,'Translation_requests_(Korean)',0,0,0),(15,'Translation_requests_(Polish)',0,0,0),(16,'Translation_requests_(Slovak)',0,0,0),(17,'Translation_requ

Try
SQL Server Migration Assistant
https://learn.microsoft.com/en-us/sql/ssma/sql-server-migration-assistant?view=sql-server-ver15&viewFallbackFrom=sql-server-2019
You need an mysql odbc driver for that (of course), because you have to connect both servers.
You can try mysqldump
mysqldump --compatible=mssql
But that doesn't work everytime, and if that sql is to big you can get problems.
the rest -u and -p you should know waht you have to add evntually you need also --extended-insert=FALSE
Also phpmyadmin has an option to make an Backup in mssql Format, for that you switch to sql compatibility, but you need a websever plus pho for that.

Related

Generate mysqldump without comments

I am generating a dump file form mysql using mysqldump -u root -p --databases dbname > dump.sql, and the file generated is as follows:
-- MySQL dump 10.13 Distrib 8.0.21, for osx10.15 (x86_64)
--
-- Host: localhost Database: dbname
-- ------------------------------------------------------
-- Server version 8.0.21
/*!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 */;
/*!50503 SET NAMES utf8mb4 */;
/*!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 */;
--
-- Current Database: `dbname`
--
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `dbname` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `dbname`;
--
-- Table structure for table `tbname`
--
DROP TABLE IF EXISTS `tbname`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tbname` (
`volume_no` int NOT NULL,
`issue_no` int NOT NULL,
`page_no` int NOT NULL,
`category` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
`title` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
PRIMARY KEY (`volume_no`,`issue_no`,`page_no`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = #saved_cs_client */;
But this has many comments and info which I don't exactly need. Is there a way to directly get output without things like /*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */; etc. as despite being comments, these are generating errors when the file is executed from a python
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */; aren't really comments even though they look that way. They are conditional-execution tokens.
however you can skip comments by --skip-comments and you can try --compact as well

How can I restore some mysqldump files to my local Joomla database?

I have these exported databases as mysqldump files. I have to restore them to my local Joomla server. The problem is that they are not have .sql format and I cannot import them to the Joomla database via the phpmyadmin dashboard because I get the message Incorrect format parameter. Also since there are multiple databases how am I supposed to set them up as a Joomla website.
Also I am using Windows 10 and XAMPP.
This some of the CREATE and INSERT queries:
-- MySQL dump 10.13 Distrib 5.6.44, for Linux (x86_64)
--
-- Host: localhost Database: athlitik_main
-- ------------------------------------------------------
-- Server version 5.6.44
/*!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 `broadcasts`
--
DROP TABLE IF EXISTS `broadcasts`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `broadcasts` (
`gid` int(11) NOT NULL AUTO_INCREMENT,
`gdate` date NOT NULL,
`gtime` time NOT NULL,
`gchannel` text CHARACTER SET utf8 NOT NULL,
`gmatch` text CHARACTER SET utf8 NOT NULL,
`gorg` text CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`gid`)
) ENGINE=InnoDB AUTO_INCREMENT=2244 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `broadcasts`
--
LOCK TABLES `broadcasts` WRITE;
/*!40000 ALTER TABLE `broadcasts` DISABLE KEYS */;
INSERT INTO `broadcasts` VALUES (2234,'2015-01-30','18:30:00','Novasports 3 ','Παμβοχαϊκός - Εθνικός Αλεξανδρούπολης','League Cup - 1ος ημιτελικός'),(2235,'2015-01-30','21:00:00','Novasports 3 ','Ολυμπιακός - Άρης','League Cup - 2ος ημιτελικός'),(2236,'2015-01-30','21:30:00','OTE Sport 1 ','Βόλφσμπουργκ - Μπάγερν Μονάχου','Bundesliga'),(2237,'2015-01-30','21:30:00','Novasports 1 ','Παρί Σεν Ζερμέν - Ρεν','Ligue 1'),(2238,'2015-01-30','21:45:00','ΝΕΡΙΤ plus ','Παναθηναϊκός - Γαλατάσαραϊ','Euroleague'),(2239,'2015-01-30','21:45:00','Novasports 4 ','Μπαρτσελόνα - Ζαλγκίρις','Euroleague'),(2240,'2015-01-30','21:45:00','OTE Sport 2 ','Ράγιο Βαγιεκάνο - Ντεπορτίβο Λα Κορούνια','La Liga'),(2241,'2015-01-30','21:45:00','Novasports 2 ','Ουνικάχα Μάλαγα - Φενέρμπαχτσε','Euroleague'),(2242,'2015-01-31','02:30:00','OTE Sport 3 ','Μπρούκλιν Νετς - Τορόντο Ράπτορς','NBA'),(2243,'2015-01-31','10:30:00','Eurosport ','Αυστραλιανό Όπεν','Τελικός γυναικών');
/*!40000 ALTER TABLE `broadcasts` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `games`
--
DROP TABLE IF EXISTS `games`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `games` (
`gid` int(11) NOT NULL AUTO_INCREMENT,
`gdate` date NOT NULL,
`gtime` time NOT NULL,
`gmatch` text CHARACTER SET utf8 NOT NULL,
`gorg` text CHARACTER SET utf8 NOT NULL,
`gstadium` text CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`gid`)
) ENGINE=InnoDB AUTO_INCREMENT=707 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `games`
--
LOCK TABLES `games` WRITE;
/*!40000 ALTER TABLE `games` DISABLE KEYS */;
INSERT INTO `games` VALUES (685,'2015-01-31','12:00:00','Α.Ο.ΧΑΝΙΑ-ΑΡΗΣ','Α\' ΕΘΝΙΚΗ ΓΥΝΑΙΚΩΝ','ΜΟΥΡΝΙΕΣ'),(686,'2015-02-02','15:30:00','Α..Ο.ΧΑΝΙΑ-ΦΩΣΤΗΡΑΣ','Κ-19 ΦΟΥΤΜΠΟΛ ΛΙΓΚ','ΑΓ.ΑΠΟΣΤΟΛΟΙ'),(687,'2015-01-31','15:00:00','ΗΡΑΚΛΗΣ ΝΕΡ.-ΑΡΗΣ ΒΟΥΚ.','Α\' ΕΠΣΧ','ΝΕΡΟΚΟΥΡΟΥ'),(688,'2015-01-31','15:00:00','ΠΑΝΑΚΡΩΤΗΡΙΑΚΟΣ-ΜΙΝΩΤΑΥΡΟΣ','Α\' ΕΠΣΧ','ΚΑΘΙΑΝΑ'),(689,'2015-01-31','15:00:00','ΑΡΗΣ Σ.-ΚΟΡΩΝΙΔΑ','Α\' ΕΠΣΧ','ΣΟΥΔΑ'),(690,'2015-01-31','15:00:00','ΣΠΑΘΑ-ΙΝΚΑ','Α\' ΕΠΣΧ','ΚΟΛΥΜΠΑΡΙ'),(691,'2015-01-31','15:00:00','ΔΟΞΑ-ΚΕΡΑΜΕΙΑ','Α\' ΕΠΣΧ','ΜΟΝ.ΕΛΙΑ'),(692,'2015-01-31','15:00:00','ΤΙΤΑΝ-ΠΑΓΧΑΝΙΑΚΟΣ','Α\' ΕΠΣΧ','ΝΙΟ ΧΩΡΙΟ'),(693,'2015-01-31','15:00:00','ΑΣΠΙΔΑ-ΑΣΤΕΡΑΣ ΜΑΝ.','Α\' ΕΠΣΧ','ΝΑΥΣΤΑΘΜΟΣ'),(694,'2015-02-01','15:00:00','ΔΑΑΟΧ-ΙΚΑΡΟΣ Μ.','Α\' ΕΠΣΧ','ΑΓ.ΑΠΟΣΤΟΛΟΙ'),(695,'2015-02-01','15:00:00','ΡΟΔΩΠΟΥ-ΙΔΟΜΕΝΕΑΣ','Α\' ΕΠΣΧ','ΚΟΛΥΜΠΑΡΙ'),(696,'2015-02-01','15:00:00','ΙΩΝΙΑ-ΠΑΛΑΙΟΧΩΡΑ','Α\' ΕΠΣΧ','ΜΟΝ.ΕΛΙΑ'),(697,'2015-01-31','15:00:00','ΔΑΦΝΗ-ΚΡ.ΑΣΤΕΡΑΣ','Β\' ΕΠΣΧ','ΕΜΠΡΟΣΝΕΡΟ'),(698,'2015-02-01','10:30:00','ΦΩΣΤΗΡΑΣ-ΧΑΛΗΣ','Β\' ΕΠΣΧ','ΝΕΡΟΚΟΥΡΟΥ'),(699,'2015-02-01','10:30:00','ΑΜΙΛΛΑ-ΑΠΟΛΛΩΝ','Β\' ΕΠΣΧ','ΠΛΑΤΑΝΙΑΣ'),(700,'2015-02-01','10:30:00','ΘΥΕΛΛΑ ΚΑΛ.-ΓΡΑΝΙΤΗΣ','Β\' ΕΠΣΧ','ΚΑΣΤΕΛΙ'),(701,'2015-02-01','15:00:00','Ν.ΣΑΜΨΩΝ-ΑΠΤΕΡΑ','Β\' ΕΠΣΧ','ΝΙΟ ΧΩΡΙΟ'),(702,'2015-02-01','15:00:00','ΠΟΣΕΙΔΩΝ ΤΣ.-ΑΕ ΚΥΔΩΝΙΑΣ','Β\' ΕΠΣΧ','ΣΟΥΔΑ'),(703,'2015-02-01','15:00:00','ΙΚΑΡΟΣ ΤΑΥΡ.-ΠΕΡΙΒΟΛΙΑ','Β\' ΕΠΣΧ','ΤΑΥΡΩΝΙΤΗΣ'),(704,'2015-01-31','15:00:00','Ν.ΚΙΣΑΜΙΚΟΣ-ΥΡΤΑΚΙΝΑ','Γ\' ΕΠΣΧ','ΚΑΣΤΕΛΙ'),(705,'2015-02-04','15:00:00','Ν.ΗΡΑΚΛΗΣ Ν.-ΤΑΛΩΣ','Γ\' ΕΠΣΧ','ΝΕΡΟΚΟΥΡΟΥ'),(706,'2015-02-04','15:00:00','Α.Π.ΣΟΥΔΑΣ-Ν.ΜΙΝΩΤΑΥΡΟΥ','Γ\' ΕΠΣΧ','ΣΟΥΔΑ');
/*!40000 ALTER TABLE `games` ENABLE KEYS */;
UNLOCK TABLES;
Try adding .sql to the dump filenames.

Restore MySQL from dump: different version and CHARACTER SET

I am moving data from my old database to my new one. The old DB uses:
MySQL version 5.5
CHARACTER SET utf8
I created a new database:
MySQL version 5.6
create database MY_DB; -- Same name as old DB
ALTER DATABASE MY_DB default CHARACTER SET utf8mb4;
Create some users, grant some privileges...
I want to create the db tables and add the data using a mysql dump file, but am concerned that the dump file will overwrite settings and variables that have been set in the new DB.
How do I:
Write the dump command such that any wrong / unnecessary settings and the db create statement are not included? This includes DB and table level settings.
or
Create tables and load data from the dump file, as is, and afterwards set all table and DB settings as they should be in the new DB?
These are the create statements and DB settings that I am seeing in the dump file:
/*!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 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `MY_DB` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `MY_DB`;
DROP TABLE IF EXISTS `MY_TABLE`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `MY_TABLE` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(80) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = #saved_cs_client */;

Get errno 150 when restoring sql dump file

I've use MySQL Dump Distrib 5.1.45 to backup my database. It's generated a file a below:
-- MySQL dump 10.13 Distrib 5.1.45, for Win32 (ia32)
--
-- Host: localhost Database: SG
-- ------------------------------------------------------
-- Server version 5.5.16
/*!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 */;
DROP TABLE IF EXISTS `hist`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `hist` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`HistUi` int(11) DEFAULT NULL,
`StdModel` varchar(30) DEFAULT NULL,
PRIMARY KEY (`Id`),
KEY `StdModel` (`StdModel`),
CONSTRAINT `FKA0015AD86A02605F` FOREIGN KEY (`StdModel`) REFERENCES `std` (`Model`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = #saved_cs_client */;
LOCK TABLES `hist` WRITE;
/*!40000 ALTER TABLE `hist` DISABLE KEYS */;
/*!40000 ALTER TABLE `hist` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `std`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `std` (
`Model` varchar(30) NOT NULL,
`Owner` varchar(30) DEFAULT NULL,
PRIMARY KEY (`Model`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = #saved_cs_client */;
But when I try to restore from that file, I fails and show a message such as:
ERROR 1005 (HY000): Can’t create table ‘SG.hist’ (errno: 150)
I try some solutions got from Google search but not work:
Add SET FOREIGN_KEY_CHECKS = 0; on top of dump file
Use mysql.exe from MySql Server 5.5
Use MySql Workbench
...
I wasted too may time on this issue but still can't find the root cause leading to the problem. I cannot use newer mysqldump.exe file to create dump file again, and don't want to change database structure now. A little change in sql dump file is acceptable.
Update:
Bring that file to other PCs which have the same MySQL server and it works fine. I tried to compare my.ini files, even copying my.ini file from another PC doesn't make it worked.
I had the same problem, which I believe was caused by tables that were expected to be created later in the same dump file already existing, perhaps with slightly different definitions. I dropped the database and recreated it from scratch and everything worked fine. Could this be your problem?

Using Script to load data into database -- sql

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.
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.
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.