Jump to content

How do you upload data from .dat file on the server database?


Ivan Ivković

Recommended Posts

We bought a database containing all the countries/states/cities in the world.

 

These are the instructions for the upload:

Step 1. Create following tables in your database with the command:
create table country(country_code varchar(2), country_name varchar(255));
create table states(country_code varchar(2),state_code varchar(20),state_name varchar(255));
create table weblocations (country_code varchar(2), state_code varchar(20),city_name varchar(255));

 

Step 2: Add unicode support to the table

ALTER TABLE country CONVERT TO CHARACTER SET utf8 COLLATE utf8_persian_ci;
ALTER TABLE states CONVERT TO CHARACTER SET utf8 COLLATE utf8_persian_ci;
ALTER TABLE weblocations CONVERT TO CHARACTER SET utf8 COLLATE utf8_persian_ci;

Step 3. Load the data using the following command. Please substitute correct path for the extracted files from the zip that we provided

LOAD DATA LOCAL INFILE 'C:/country.dat' INTO TABLE country CHARACTER SET UTF8 fields terminated by '\t' LINES TERMINATED BY '\r\n'; 
LOAD DATA LOCAL INFILE 'C:/states.dat' INTO TABLE states CHARACTER SET UTF8 fields terminated by '\t' LINES TERMINATED BY '\r\n'; 
LOAD DATA LOCAL INFILE 'C:/weblocations.dat' INTO TABLE weblocations CHARACTER SET UTF8 fields terminated by '\t' LINES TERMINATED BY '\r\n'; 

Step 4. Verify that the data has been loaded.

SELECT * FROM country;
SELECT * FROM states;
SELECT * FROM weblocations;

 

I've tried uploading to my local database server and it works like a charm, but I can't export more than 40 mbs of data (there's around 100) since php.ini has maximum_executing_time to maximum of 300 seconds, and that's still not enough.

 

The problem is. What do I type in instead of 'C:/country.dat' and for other files? I can't find any mysql folder in my cPanel to move my files to that folder...

And what is the format of my link to the file? Is it http://www.mysite.com/country.dat or is it standard stuff like C:/something/something/country.dat?

 

This is my folder structure:

 

 

(/home/social)

access-logs

bin

etc

 

mail

perl

php

 

public_ftp

 

public_html

tmp

 

www

application

application_blog

cgi-bin

cometchat

externals

install

public

temporary

 

Link to comment
Share on other sites

Shell access button? You generally access the shell via an ssh client. You may however have some web based shell emulator that will suffice (this sounds like what your looking at).

 

Login via that and execute the appropriate commands.

Link to comment
Share on other sites

By the way, if you help me, as a gift I will put the whole cities - countries - states database in SQL format and put it on this website in a torrent file / upload link.

 

That will get you banned.

 

I don't see any shell client option. :/

 

I suggest you contact your host and ask them if you have shell access.

Link to comment
Share on other sites

You need shell access to be able to do this. Either that, or create the database locally, then make a dump of that. You should have some method of importing a database from a dump available through your control panel.

 

That's most likely your best solution.

Load the data into mysql using a local version of wamp/xampp or whatever package you use.

Increase the limits for timeout and size on your local install to accomplish your goal.

Once you have the data loaded into database, you can export, then import one table at a time into a new database at your server.

 

I've even just copied the MySQL/data/database_folder_name files from the folder, then do a repair on the tables.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.