I have a .sqlite file which I want to convert into mysql. So is there any way to convert it into mysql?I am using ubuntu. So is there any shell script to change it. Any help will be highly appreciable.
assuming your sqlite db file is login.db
download this script as sqlite3-to-mysql.sh
this command will tranform your sqlite db file to standard mysql sql file: sqlite3 login.db .dump > sqlite.sql && bash sqlite3-to-mysql.sh sqlite.sql > mysql.sql && rm sqlite.sql
import to mysql: mysql -uuser -ppassword -D database < mysql.sql
I've tried this recently and most answers don't work because they're out of date. e.g. python vs python3
A method that worked for me that should never go out of date is to export the tables to CSV and then import them as CSV. I used Sequel Pro which can import a CSV. The downside is that you need to do each table individually. The upside is that this is a very robust method and doesn't require any custom scripts.
Run the following in your database folder changing "thedatabase" and the two occurances of "thetable" to the database name and table name respectively:
sqlite3 -header -csv thedatabase.db "select * from thetable;" > thetable.csv
For Sequel Pro:
Create your database
(Optional: Create table structure. Recommended to have the correct column types) You could get the create statement from an sqlite dump and fix them for mysql.
File > Import
Format: CSV
Check: "First line contains field names"
Check the field mappings and import
Explanation of the command to export:
"sqlite3" is the command line client for sqlite databases.
"-header -csv " sets the output to csv
"thedatabase.db" is the database file
"select * from thetable;" is the query to select all data from the table
" > thetable.csv" redirects the output of the data to thetable.csv file
1) Export sqlite database to sql file
sqlite3 sqlite.db .dump > mysql.sql
2) Import mysql.sql file to mysql database using phpmyadmin or other tools.
To directly import it to the database in just one command:
sqlite3 database.db .dump | mysql -uuser -ppassword database
Google "sqlite to mysql" will give you a lot of articles doing that ...
Okay, easiest is to open the .sqlite file using sqlite, .dump to a file, and the file is a text file containing SQL statements.
You shall be able to edit that file and run in your mysql DB thereafter.
Related
I'm trying to import existing database file into an empty SQL database with the following command:
mysql -u username -p'password' db_name < dbfile.sql
but I get following Error:
ERROR 1146 (42S02) at line 1: Table 'db_name.oc_address' doesn't exist
I know that oc_address is a table name inside the SQL file, but I don't know what to do to import it correctly, I searched the web and also stack-overflow, found nothing on this error.
Download the actual opencart zip file
https://www.opencart.com/index.php?route=cms/download/download&download_id=62
Unzip it
open folder
\upload\install
and
run opencart.sql
if you have installed extensions that have need their own sql, you have to run their sql as well
After that run you backup file
To export an entire database and then load it into another server, your best bet is to use the mysqldump command line utility. Its export files contain the data definition language (tables, views, all that) for the database as well as the data.
You can also get it to export just the definitions.
mysqldump --no-data -u username -p'password' db_name > opencartddl.sql
Then you can import that file first, then your data file.
Or, you may be able to stand up a new, empty, Opencart instance and use its UI to import your data.
It's probably wise to avoid trying to write replacement DDL yourself if you can get a tool like mysqldump to do it.
I am trying to upload a sql file in the database I am running following code
# mysql - u root -p idecon123 < "d:\IdeOffline\answersnew.sql"
But when I parse this it shows the help manual .
Is there any mistake in my command
Thanks
Go to http://localhost/ after starting Apache and MySQL. On the left side you will see a link for phpMyAdmin. Click that, then upload your .sql file through the browser. See http://wiki.phpmyadmin.net/pma/import for how to import files.
edit: for big files, set an uploadDir per http://docs.phpmyadmin.net/en/latest/config.html . Copy the file into that directory and you'll be able to import it directly.
You can do that by using the mysqlimport command in the command prompt.
Here is the syntax,
mysqlimport -u root -p abc#123 --ignore-lines=1 --fields-terminated-by="," --lines-terminated-by="\n" --local upam_dev C:\Users\ukrishnan\Desktop\Generated-Players\PlayerProfile.dataSet-1.csv
--ignore-line - To exclude if you have something like title in your first line of CSV
--fields-terminated-by - Can specify, how the field is terminated like , or | symbol
The filenames must correspond with the tables into which their data will be imported. If a filename contains one or more . (dots), the portion before the first dot will be assumed to be the name of the table.
If you have data in multiple files, you can specify like Profile.File-1.csv, Profile.File-2.csv. So that it will take the table name as Profile when you import these files.
These is ultimately fast when compare with the importing through PhpMyAdmin. It took me around 3-4 seconds to import a file with 100K records.
i have a .sql file that was exported from wamp, my friend only uses xampp. Is it possible to import my .sql file to xampp?
Yes because the .sql file is most likely independent of the server stack.
Of course it is possible, when wamp give you a export of .sql, this file can be used with all standard web server. (xampp)
I think this may help
Depending on the tool and parameters used to create the .sql dump file of multiple databases, the file will normally have
CREATE DATABASE DBn...;
and
USE DBn;
statements that will allow your import to proceed without hiccups. For example, both the mysqldump command mysqldump command and phpMyAdmin's Export function for multiple database insert them.
Assuming you have exported with a sensible tool like those above, then you can import the database with a command line like this:
mysql -u username -p < dumpfile.sql
Your mysql username account needs to have appropriate privileges to, for example, create databases.
You can even run this command in a more familiar way by naming the startingDB database to use before running the commands in dumpfile.sql:
mysql -u username -p startingDB < dumpfile.sql
Currently, I am using mysql version 5.0.45 - community-nt. I have created tables in that database. After that, I export the script file from and I imported other mysql server. That version is 5.5.29. In my tables, there is BIT datatype. When I imported my exported data to other mysql version, the imported data are changed. Imported data are not correct. So, How shall I handle.
If you're exporting with the mysqldump command you can use the --compatible option. For some reason there isn't a mysql50 option but you can use mysql40 and it should work for you:
mysqldump -uuser -ppassword -hyour.host \
--compatible=mysql40 your_database > your_database.sql
I want to import an sqldump file in my database "dbname" into the table "data" without using the network interface.
when i import the file via
mysql dbname -u databaseuser -pdatabasepass<data.sql
this is really slow on my ubuntu 12.04
but when i use this instead:
mysqlimport -u databaseuser -pdatabasepass --local data.sql
it is as fast as normal.
i think, because on my mashine it is parsing each line separately when using "mysql" and "<"
is there a way to use the mysqlimport syntax for importing an sql-file with CREATE and DROP TABLE stuff?
maybe just split the upper part in the sql-dump (with the drop table and create table statement) automatically and then only send the rest of the file with the INPUT-statements to mysqlinsert, that should work
There is no way to do that directly. What you need to do is run mysqldump --tab instead of the normal mysqldump, that will create both a .sql files containing table definitions and a CSV file containing data that can be imported with mysqlimport.
You can specify the path to a UNIX socket file with --socket=/path/to/... (or -S), which may be faster. You can find the socket path in the server's my.cnf. So, for example (and I'm just making up the path, here);
mysql dbname -u databaseuser -pdatabasepass -S /var/run/mysqld/mysqld.sock < data.sql
You can use this script: How do I split the output from mysqldump into smaller files?
and modify it, so you have only the create-statements in one file and the data statements in another.