0
votes

I'm having a error when I try to import wordpress database into phpmyadmin. Error msg

-- -- Databas: 133425-admin -- USE 133425 - admin;

MySQL sa: Dokumentation

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use

near '133425-admin' at line 4

And the first line in the .sql file is

-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Värd: 127.0.0.1
-- Tid vid skapande: 04 nov 2016 kl 08:56
-- Serverversion: 10.1.16-MariaDB
-- PHP-version: 5.6.24

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!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 */;

--
-- Databas: `133425-admin`
--
USE 133425-admin;
-- --------------------------------------------------------

--
-- Tabellstruktur `django_migrations`
--

CREATE TABLE `django_migrations` (
  `id` int(11) NOT NULL,
  `app` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `applied` datetime(6) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

The only thing that have changes from my old database to this one is the name 133425-admin so I added USE 133425-admin; When importing the .sql file into a database named the same as before it is successfull.

Is the USE.... line wrong?

Here's a screenshot of the problem:

Picture of the problem

1
Usually when you export a database from phpMyAdmin, it adds a 'CREATE IF NOT EXISTS' query for a database. But in this case, it is explicitly mentioned to use a certain database. So, that's the reason you're able to successfully import it into a db of the same name. USE is not wrong but the export procedure must've been different in your case so as to result in this kind of an SQL dump. - Gaurav Ojha
Does the database 133425-admin exist ? If so, what happens if you use backticks, like USE `133425-admin;` ? - roberto06
USE `133425-admin`; instead of USE 133425-admin; - coder
@coder That gives me a error too, I know the sql code is not the problem. When I use my local phpmyadmin and I call the databasename as is was original it works. pic of error i.stack.imgur.com/QRWZE.png - Lorr
not USE `133425-admin;`! use instead USE `133425-admin`; - the semicolon after the last backtick! - Sebastian Brosch

1 Answers

0
votes

Better to try import via command line, here is the example :

mysql -u username -p database_name < file.sql

Before you import, make sure you create the empty database name.