Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm struggling to do this.

I have created a new database in the terminal called "somedb" using

CREATE DATABASE somedb

On my desktop I have the SQL dump downloaded from phpMyadmin: somedb.sql

I have tried:

somedb < /Users/myname/Desktop/somedb.sql

Result: ERROR 1064 (42000): You have an error in your SQL syntax

mysql -u myname -p -h localhost somedb </Users/myname/Desktop/somedb.sql

Result: ERROR 1064 (42000): You have an error in your SQL syntax;

I'm new to SQL (The purpose of importing this db is for a text book exercise)

I have granted myself all privileges and there is no password.

Any idea what I'm doing wrong?

Here is the top of the SQL dump file:

-- phpMyAdmin SQL Dump
-- version 4.0.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 18, 2013 at 02:22 PM
-- Server version: 5.5.31-30.3
-- PHP Version: 5.2.17

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

--
-- Database: `somedb`
--
CREATE DATABASE IF NOT EXISTS `somedb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `somedb`;

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

--
-- Table structure for table `actions`
--

CREATE TABLE IF NOT EXISTS `actions` (
  `action_id` int(11) NOT NULL AUTO_INCREMENT,
  `action` varchar(75) NOT NULL,
  `qualifiers` text NOT NULL,
  `response` varchar(75) NOT NULL,
  `response_vars` text NOT NULL,
  `active` tinyint(4) NOT NULL,
  PRIMARY KEY (`action_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='Stores user defined actions triggered by certain events' AUTO_INCREMENT=3 ;

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

--
share|improve this question

1 Answer

up vote 0 down vote accepted

I found an SO post here.

I used "source" like so:

SOURCE /Users/myname/Desktop/somedb.sql;

That worked. Great but the internet seemed to want me to use the method like so:

mysql -u username -p password databasename < filename.sql

I may post another question on when to use that second method but in the meantime I just used source from a SQL dump file

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.