Importing database wordpress

Discussion in 'Web Design and Development' started by Dal123, Oct 11, 2010.

  1. Dal123 macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #1
    I recently changed servers and I think I have made a terrible mistake, I tried backing up my wordpress blog from this tutorial http://www.clockwatchers.com/mysql_dump.html however when I go to import the database I get this "Error

    Code:
    SQL query:
    
    --
    -- Database: `preciseformworkcouk_434616_db1`
    --
    -- --------------------------------------------------------
    --
    -- Table structure for table `truewp_commentmeta`
    --
    CREATE TABLE IF NOT EXISTS `truewp_commentmeta` (
    `meta_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
    `comment_id` bigint( 20 ) unsigned NOT NULL default '0',
    `meta_key` varchar( 255 ) default NULL ,
    `meta_value` longtext,
    PRIMARY KEY ( `meta_id` ) ,
    KEY `comment_id` ( `comment_id` ) ,
    KEY `meta_key` ( `meta_key` )
    ) ENGINE = MYISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT =4;
    MySQL said: Documentation
    #1046 - No database selected " which looks very worrying to me. I have read through the .sql file that it creates and there is some information in there from my previous posts etc. This isn't supposed to be too hard but I've spent about 5 hours trying every little thing. I wonder if anyone out there would be able to help me out and check that I backed it up properly in the first place?
    Any ideas on how I can check, I don't think I backed it up properly, I only have a .sql file. I have read through it and it has got some stuff in there from my previous posts.
    Any advice greatly appreciated.
     
  2. Dal123 thread starter macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #2
    hmmm I have managed to import it now, it's looking better than before. I now have the tables from the database showing so I'm a bit more confident that I backed it up properly.
    I'll try checking all configurations are correct and that wordpress is acutally installed properly etc.
    For those who this could help in the future, I think the existing database had to be selected and imported into that.:eek: Though I'm sure I tried that about ten times alreadly.
    I think the database is there and the info, however something is wrong as I cannot load the site on my hosting site. I also forgot the names of pages etc, thoough I have my username etc noted down how would I find this info through phpmyadmin? Just for future reference!
    I have checked my config.php file and made neccessary changes for my new username and database etc. So not sure whats going on at the minute.
     
  3. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #3
    Right. Normally the database name and related directives are not included in a "default" export because people frequently do backups or migrations where the database name is likely to change. It is common to first have to create and use the database (whatever name) so the import works.

    As to the other issues, check to make sure the hostname/IP settings have changed in the config.php or any PHP code where such settings must be set (modules, themes, cookie settings, etc.)

    -jim
     
  4. Dal123 thread starter macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #4
    Thanks Jim. I got some other input from a friend, and I didn't back it up properly when I did it on this tutorial http://www.clockwatchers.com/mysql_dump.html, not sure what I did wrong.
    Anyway I lost my whole wordpress site / blog :mad:. I am so gutted :(. So I'm beginning building it all again :p. I find wordpress quite hard work, as when you go to edit you need to have a fair understanding of php :eek:.
    K I've created a new site (1 whole post with wordpress) and I'm trying to upload it to my server. I go to import the database and I get #1044 - Access denied for user 'precisef'@'localhost' to database 'blog_db', which would suggest I have wrong config.php I guess??

    Thanks for input much appreciated.
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    The error mentions "localhost," which only applies to when you're doing your local setup. You need to change the host.
     
  6. Dal123 thread starter macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #6
    Thanks for your comments; are you sure? I have contacted my web host and they assure me that 'localhost' is correct.:confused:
    Also when watching many other tutorials, they leave it as 'localhost'.

    Can anyone point me in the direction of a decent tutorial, showing the whole process;
    Backing up a blog via phpmyadim
    New domain, installing wordpress again
    Restoring old wordpress site from old back-up.

    I have watched about thirty tutorials on youtube, and read about ten online also. I don't understand the wordpress platform, I know it's a database, and there are tables in it. But not sure where the data actually is. I think it's in the tables, but really don't understand it all.
    This would be a good tutorial for someone to do on youtube, as many of them do show most of the process, but miss-out vital parts.
     
  7. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #7
    RE: localhost - only use this hostname when accessing the database from the same server the database is located. Otherwise use the hostname or IP of the database server, or your domain name if the same IP.

    In many phpMyAdmin setups, the user/password setup in config.inc.php determines the "power user" which is used only for administering MySQL including export/import of your database data:

    Log into phpMyAdmin as root or whatever name you use for the power user, do your export/import creating and switching to databases as necessary manually via phpMyAdmin's menu system.

    Also select the "Privileges" tab and make the adjustments there for any users making connections to those databases via their web sites. A good strategy is to create one user (precisef) associated with one database (blog_db) which is allowed access from a specific IP or hostname when connecting remotely (i.e. the web server) or localhost if on the same server as the database server. Assign all privileges accept those in the "Administration" options, for example.

    -jim
     
  8. Dal123 thread starter macrumors 6502a

    Dal123

    Joined:
    Oct 23, 2008
    Location:
    England
    #8
    Thanks Jim, How do I get this information; they are telling me all I need is 'localhost', but they must be wrong.
     
  9. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #9
    If WordPress is reporting "Access denied for user 'precisef'@'localhost' to database 'blog_db'" that means:

    1) It expects a user in MySQL daemon to exist and be named "precisef"
    2) It expects you typed in the proper password for that user in config.php
    3) It expects MySQL to be on the same machine (the web host)
    4) It expects that user to have the necessary priviledges for that database
    5) It expects that user to be able to access from "localhost" explicitly

    All these things are setup in MySQL and can be managed using phpMyAdmin as discussed earlier (preferred for novices) or in the daemon itself via shell (gurus). If you are not sure about MySQL permissions and how they work you need to learn, or ask your webhost to "set it up for you" so all 5 conditions above are true.

    -jim
     

Share This Page