I can not restore database in mysql

0

I'm trying to restore a DBS that I have on my machine, but unfortunately I'm having problems ...

ERROR 1064 (42000): 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 'mysql -u root -h localhost -p reg_users < /home/ubuntu/workspace/restore.sql' at line 1

This is the error that is returning, please help me

My DBS (Restore.SQL) ...

-- phpMyAdmin SQL Dump
-- version 4.7.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Tempo de geração: 05/05/2017 às 18:41
-- Versão do servidor: 5.7.17
-- Versão do PHP: 5.6.30

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
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 */;

--
-- Banco de dados: 'reg_users'
--

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

--
-- Estrutura para tabela 'user_civ'
--

CREATE TABLE 'user_civ' (
  'nome' varchar(100) NOT NULL,
  'usuario' varchar(100) NOT NULL,
  'senha' varchar(100) NOT NULL,
  'edereco' varchar(200) NOT NULL,
  'userCivCod' int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

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

--
-- Estrutura para tabela 'user_ong'
--

CREATE TABLE 'user_ong' (
  'nome' varchar(100) NOT NULL,
  'nome_ong' varchar(100) NOT NULL,
  'senha' varchar(100) NOT NULL,
  'userOngCod' int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Índices de tabelas apagadas
--

--
-- Índices de tabela 'user_civ'
--
ALTER TABLE 'user_civ'
  ADD PRIMARY KEY ('userCivCod');

--
-- Índices de tabela 'user_ong'
--
ALTER TABLE 'user_ong'
  ADD PRIMARY KEY ('userOngCod');

--
-- AUTO_INCREMENT de tabelas apagadas
--

--
-- AUTO_INCREMENT de tabela 'user_civ'
--
ALTER TABLE 'user_civ'
  MODIFY 'userCivCod' int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT de tabela 'user_ong'
--
ALTER TABLE 'user_ong'
  MODIFY 'userOngCod' int(11) NOT NULL AUTO_INCREMENT;COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
    
asked by anonymous 05.05.2017 / 19:55

1 answer

1

You are not selecting which database to receive your SQL file. Please try the following step:

  • mysql -u root -h localhost -preg_users
  • After Log:

  • create database reg_users;
  • Use reg_users;
  • source /home/ubuntu/workspace/restore.sql;
  • If you notice, your SQL file is not specifying the line CREATE DATABASE IF NOT EXISTS reg_users;

    This line serves to create the Bank if it does not exist.

        
    05.05.2017 / 22:42