How to import text file into database?

Posted on 2014-08-27
Last Modified: 2014-09-10
This is using mysql in a CentOS server. A database named AA is created. My development passed me a text file (.txt) and want me to import into this AA database, how should I do it? This is using for a wordpress web site, and numeral tables, such as, wp-commentmeta, wp-comment, wp-links, wp-options are there.

Please show step-by-step. Thanks first.
Question by:MichaelBalack
    LVL 107

    Accepted Solution

    If you're new to PHP and MySQL, this article can help you get the foundation you need.

    In order to help with this, we would need to see the columns in the data base tables and the data in the text file.  As far as i know there is no "one-size-fits-all" method of importing text into a data base table, since there can be any number of data elements in either.

    If you can post the CREATE TABLE statement for the tables in the AA database, along with a bit of the test data from your text file, we may be able to help you get started.  Or we may advise you to be respectful of your time and just hire an experienced programmer.
    LVL 1

    Author Comment

    Hi Ray,

    Thanks for your advice.

    This AA is a new web site built on Wordpress. Maybe I go through the setup process down here. At first, apache web server is setup, follow by mysql & php, both with version 5.x. After that, I move this AA folder (created by my web vendor), to /var/www/html; Please see the folder list (of AA) as follows:

         -- cgi-bin (folder)
         -- wp-admin (folder)
        -- wp-contents (folder)
        -- wp-includes (folder)
        wp-admin.php, index.php

    Open the wp-admin.php, and change the DB_User, DB_password, DB_host, etc correctly; Database name is AK. Use
    MySQL command, type "mysql -u root -e create database AA"; to create AA DB.

    In MySQL, after "use AA", and then type "show tables" with list of tables in display as follows:


    I also setup the adminer in Wordpress. When I tried to import the txt file (2.3 Mb), the following oversize error occurs:

    Please see the attached adminer_error1

    LVL 1

    Author Closing Comment

    As Ray suggested, I don't even know how to conduct the commands as stated, I have outsource the whole tasks to a web-hosted provider.
    LVL 107

    Expert Comment

    by:Ray Paseur
    I think outsourcing this is a very good idea!  Thanks for the points, ~Ray

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Suggested Solutions

    So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
    Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
    The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
    The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: : Click on Too…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now