I cannot restore database in mysql

Asked

Viewed 330 times

0

I am trying to restore a DBS I have on my machine, but unfortunately I am 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 */;

  • Dude, the bug already says, 'syntax error,' I suggest you post what you think is happening(code) here.

  • what else can I post? my DBS? what code? refers to the command used? if it is already in the post, but I will comment here tbm "mysql -u root -h localhost -p reg_users < /home/Ubuntu/Workspace/Restore.sq"

  • Put the Restore.SQL, because I ran the command on my mysql and it worked

  • This command you mentioned above needs to be run via the command line. Is that what you’re doing? By the error message, it seems that you are trying to run it as if it were a query.

1 answer

1


You are not selecting which database will receive your SQL file. Try to perform the following step:

  1. mysql -u root -h localhost -preg_users

After Logar:

  1. create database reg_users;
  2. Use reg_users;
  3. 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 is used to create the Bank if it does not exist.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.