I have a text file with a single word per line. Example:
By
the
shore
of
the
ocean
I want import them into a sql database called words.sql.
When I try to do it, I get this error:
mysql> use words;
Database changed
mysql> LOAD DATA LOCAL INFILE '/home/admin/words/words.txt' INTO TABLE words;
ERROR 1148 (42000): The used command is not allowed with this MySQL version
I launch mysql with this command:
mysql -u root -p -D words --local-infile=0
What can I do to import this text file into my database? What am I doing wrong?
I have another text files of famous quotes I want to put into a database called quotes but need to figure out how to tackle this before I go any farther.
Thank you in advance.
(I have gotten these commands from various other websites in case you were wondering how I came about using these commands)
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'm learning SQL - working my way through a book.
I have mysql client set up and running. I have added and created databases and tables manually, no more than about ten records and fields.
I'm now working through a chapter all about selecting records based on criteria.
I would therefore like to import a larger database to play around with. I have downloaded the "world.sql" file from mysql.com. This file contains all of the worlds cities and associated data such as population - a good table to play around with.
I have downloaded the file to my desktop but I do not know how to actually add to a database in order to use.
I created a new database in the terminal called "world". I now need to import the sql file to this database but do not know how to?
What commands am I looking for here?
Call mysql from the shell and pipe the world.sql file to it:
$ mysql -uYOURUSER -pYOURPASSWORD < world.sql
/Applications/MAMP/Library/bin/mysql -u root -p {db_name} < {path_to_file/file.sql}
OR
/Applications/MAMP/Library/bin/mysql -u root -p
enter password then
use db_name
then
source path_to_file/file.sql
if you get foreign key error than first use following command before import
SET FOREIGN_KEY_CHECKS=0;
Then
source path_to_file/file.sql
I created a data base using mysql. I used MySQLDump to create one database backup file in text format (MySql 5.5 on Windows XP). The database is local on my machine (local host).
I am having trouble using the MySQL command to load the dump file to restore the database. I have done the following:
Research stack overflow for how to do it. I noticed there's a bug using the MySQL command to restore the data from a post. Before I run the command, I DROP the database and CREATE the database using MySQL workbench.
I type the following command in the DOS prompt to restore the database:
mysql -u root -p -h localhost -D matlab_data -o < backup.sql
backup.sql is a the backup file in text format created by MySqlDump.
I am then asked for the password which I enter. I get the DOS prompt right away with no error message. I've waited several hours for the command to run and the database is still empty.
I have tried various command formats over the last few days. If I enter incorrect data in the command line (non existen file, database, etc), I get an error message.
I feel I would not see the DOS prompt until the database is restored. If I don't DROP and CREATE the database, I get an error message. Otherwise, not.
Does anybody have any idea what the issue is? I realize that I could be making a stupid mistake.
Thank you for your help.
shell into the mysql console and run the sql file as this
If you are already running mysql, you can execute an SQL script file using the source command or . command:
mysql> source file_name
mysql> \. file_name
note that file_name must be an absolut path
Scenario: building a RoR enviroment locally for development. Production is on EngineYard / GitHub. All now working ok, except DB isn't importing.
I have a .sql file that i've taken from my prod EY site. Now i need to import it to my MySQL locally. I'm using Workbench (as i'm new to this), but getting error below.
Please help?
08:07:43 Restoring /home/james/Downloads/Futology.sql Running: mysql
--defaults-extra-file="/tmp/tmpAVeE58/extraparams.cnf" --host=localhost --user=root --port=3306 --default-character-set=utf8 --comments < "/home/james/Downloads/Futology.sql" ERROR 1046 (3D000) at line 22: No database selected
Operation failed with exitcode 1 08:07:43 Import of
/home/james/Downloads/Futology.sql has finished with 1 errors
Workbench doesn't know the database (schema) you want to use.
In workbench, when using Data Import/Restore, just below where you choose the file to import, it asks "Default Schema to be Imported To"
Just choose the database (schema) you want it to use from the dropdown titled Default Target Schema. If you don't have a database (schema) already, you can create it with the "New" button.
This is confusing because MySQL generally seems to use the term database but Workbench uses schema. They mean the same thing for most purposes. MySQL 'create schema' and 'create database' - Is there any difference
Not used Workbench too much however it's easy enough to do from command line have a look at this (below phpMyAdmin instructions)
The command you're after is:
mysql -u #username# -p #database# < #dump_file#
Simply by choosing your target schema
As I circled in above image
Similar to brynn's answer, simply modify your SQL file and insert the following line at the very top:
use yourdatabasename
Replacing yourdatabasename with the database into which you are trying to import. Also, this database should already be created (albeit empty) before you import into it.
Here's another option that worked for me. I'm using MySQL 5.5 on a VM I set up for importing a large MySQL .sql dump that contained: 1). a create table statement 2). insert statements for inserting a large amount of data into the table.
at the MySQL command line client prompt type:
use yourdatabasename
source d:\yourpath\yourfilename.sql
for more info on the 'source' and other commands, enter ? at the prompt.
The above command line is correct. I found I have to do this when importing .sql files from older versions of MySQL. I also found I had to edit the .sql file (top of the file) and set the db name to be the same as the blank db you create before doing the import.