Import CSV file into MySQL without using load data infile - mysql

I have recently switched web hosting providers and the new provider does not allow 'load data infile' commands in MySQL. However, I have many CSV files that update tables in a database weekly using that command. What is the best way to import into MySQL without the typical load data option? I tried mysqlimport, but that seems to fail since the data isn't in SQL format, its just standard CSV data. Thanks for your help.

Use the following process:
Convert the CSV to the MySQL CSV dump format
Upload the file to the MySQL server or to the shared hosting file system
Use one of the following commands to import it:
mysqladmin:
mysqladmin create db1
mysql db1 < dump.csv
mysql:
mysql> CREATE DATABASE IF NOT EXISTS db1;
mysql> USE db1;
mysql> source dump.csv
References
MySQL :: MySQL 5.7 Reference Manual :: 7.4.2 Reloading SQL-Format Backups
Text::CSV::Auto - Comprehensive and automatic loading, processing, and analysis of CSV files. - metacpan.org
MySQL :: MySQL 5.7 Reference Manual :: 8.4.3 Dumping Data in Delimited-Text Format with mysqldump
Restore data from a tab delimited file to MySQL - Electric Toolbox
Using mysqldump to save data to CSV files - Electric Toolbox
Mysqldump in CSV format

Related

Moving mySQL data to postgres, using a PostgreSQL schema file

I have a PostgreSQL schema file, and I have an SQL dump from a MySQL database. I want to know how I can import my MySQL dump file into Postgresql, using the postgresql schema file.
You cna't direct restore mysql dump file into postgres
You use psotgresql wiki or specific software trasnfer like:
Postgresql wiki
ESF Database Migration Toolkit
Can you install another MySQL, load the dump there, and export the data in CSV format? This should allow you to load the data into PostgreSQL, using the COPY command.

Import from MySql dump to hive

I am facing a problem while importing MySql dump into Hive.
I used sqoop connector to import data from MySql to Hive successfully. However, there are more data dumps to import to Hive. Restoring the database first is not feasible. Since the dump size is of 300G, hence takes 3 days to restore. Also, I can't restore more than two files on MySql because of disk space issue.
As a result, I am looking to import data, which is in MySql dump, directly into hive without restoring into MySql.
There is one more problem with the MySql dump is that there are multiple insert statements (around 1 billion). So will it creates multiple files for each insert? In that case, how to merge them?
You can use the "load" command provided by Hive to load data present in the your local directory.
Example: This will load the data present in the file fileName.csv into your hive table tableName.
load data local inpath '/tmp/fileName.csv' overwrite into table tableName;
In case your data is present in the HDFS.Use the same load command without local option.
Example:Here /tmp/DataDirectory is a HDFS directory and all the files present in that directory will be loaded into Hive.
load data inpath '/tmp/DataDirectory/*' overwrite into table tableName;
Caution: As Hive is schema on read make sure to take care of your line delimiter and field delimiter are same in both the file and the Hive table you are loading into.

MySQL WorkBench: dumping whole data base in one sql file

I'm using MysQL 5.6 and MySQL 6.1 WorkBench. I found this on how to dump whole data base
with values, but the problem is it separates every table into one sql file. How can I dump whole data base to only one sql file?
Use the Option "Export to Self-Contained File to dump the selected database(s) into one sql file:

Exporting data from HBase to MySql

I'm using HBase 0.92.1-cdh4.1.2. I have almost 100 tables in HBase [Size about 10GB]. I want to export all the data to MYSQL. I think sqoop isn't an viable option as it is used mostly to export from sql-nosql databases. And an other option would be exporting HBase data as flat files to local file system and dump the data to mysql using mysqlimport option !
Is there anyway, we can directly dump the data to mysql rather than exporting as flat files?

Mysql : Dump/Exports existing data to a .sql file

I have a database. All I want to do is dump ALL the existing data in every table to I can then use it to simply import the SQL to my new database?
Im presuming the dump will be a bunch of MySQL INSERT statements
You can also use mysqldump, native mysql tool for this purpose.
You can use a tool such as mysql workbench or phpmyadmin to create the dump.
It will be a bunch of inserts as well as all the other data in it (such as procedures).