Newbie needs help with MySQL command line

Discussion in 'MySQL' started by Jude Vihervaara, Dec 21, 2009.

  1. #1
    Hi,

    I'm quite a newbie with MySQL and I've been using mostly phpMyAdmin, but now I have big chunks of databases tha I should move from a server to another.

    I've succesfully dumped sql-files with phpMyAdmin and now I like to import these files to my new server (MacOS X Server with MySQL 5.x). I have tried little workin with command line and I've been succesfully looking databases with

    mysql> show databases;

    with result

    +----------------+
    | Database |
    +----------------+
    | adlogger |
    | adlogger2 |
    | b2 |
    +----------------+

    I heve created db with

    mysql> CREATE DATABASE db_name;

    and looking tables with

    mysql> SHOW TABLES;

    But when I try to dump a db with command line with

    mysql> mysqldump -u my_username -p my_db > mydb_backup.sql

    I get result

    ERROR 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 'mysqldump -u my_username -p my_db > mydb_backup.sql' at line 1

    I've been looking for several manuals and help pages, but no luck.

    Same thing happens when I try "mysql dbname < database_bu.sql"

    Then the error number is 1064: (42000) at line 1

    I'm despered. and :confused:
     
    Jude Vihervaara, Dec 21, 2009 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    To import database, use command mysql on shell (OS command line) not on mysql command line like this
    mysql dbname < database_bu.sql
    Code (markup):
    You may need to specify mysql username and password to import database.

    mysqldump is use to export database on shell which you have already created using phpMyAdmin.
     
    mwasif, Dec 21, 2009 IP