How do I import my SQL databases?

Discussion in 'Site & Server Administration' started by elektrisk, Apr 13, 2010.

  1. #1
    Hello.

    I'm helping a friend transfer hosts. Before we dropped the other host, I backed up the FTP and the SQL databases. His forum is running MyBB. How can I import the SQL databses which I backed up? The archive is a .zip. I went to phpyMyAdmin, but I got this error when trying to import the databases:

    SQL query:
    
    --
    -- Database: `20x_5303509_user_db`
    --
    -- --------------------------------------------------------
    --
    -- Table structure for table `mybb_adminlog`
    --
    CREATE TABLE IF NOT EXISTS `mybb_adminlog` (
    `uid` int( 10 ) unsigned NOT NULL DEFAULT '0',
    `ipaddress` varchar( 50 ) NOT NULL DEFAULT '',
    `dateline` bigint( 30 ) NOT NULL DEFAULT '0',
    `module` varchar( 50 ) NOT NULL DEFAULT '',
    `action` varchar( 50 ) NOT NULL DEFAULT '',
    `data` text NOT NULL ,
    KEY `module` ( `module` , `action` )
    ) ENGINE = MYISAM DEFAULT CHARSET = utf8;
    
    MySQL said: Documentation
    #1046 - No database selected 
    Code (markup):
    What could be the problem?
     
    elektrisk, Apr 13, 2010 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    did u create a database first .. ??
     
    Bohra, Apr 13, 2010 IP
  3. peddu

    peddu Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can easily restore or import MySQL data with mysql command itself. First you need to login to your system using ssh or putty (from Windows based system). For example:

    Type the following command at the shell prompt:

    $ ssh
    Now type following command to import sql data file:

    $ mysql -u username -p -h localhost data-base-name < data.sql
    If you have dedicated database server, replace localhost name with actual server name or IP address:

    $ mysql -u username -p -h 202.54.1.10 databasename < data.sql
    OR use hostname such as mysql.hosting.com

    $ mysql -u username -p -h mysql.hosting.com database-name < data.sql
    If you do not know the database name or database name is included in sql dump you can try out something as follows:

    $ mysql -u username -p -h 202.54.1.10 < data.sql


    Peddu
    hostcats.com
     
    peddu, Apr 15, 2010 IP
  4. sysadmin

    sysadmin Peon

    Messages:
    111
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello,
    ----------
    MySQL said: Documentation
    #1046 - No database selected
    --------
    if you are restoring it via phpmyadmin , please make sure to create a db
     
    sysadmin, Apr 15, 2010 IP