Hello im creating a batch file to install the wampserver . After that i want to import my name.sql file into the dabase that wampserver created. Im using this command :
mysql --u [bonis] --password=[bonis] ["jdbc:mysql://localhost"] < ["C:\Documents and Settings\Bonis\Desktop\bpx.sql"]
pause
And telling me this : "The filename, directoryname, or volume label syntax is incorrect."
Any ideas?
Use the following command line: mysql < name.sql
Your sql code in the file has to contain "create database" and "create table" commands, though.
Related
I am trying to export mysql table data to csv file using batch file.
It works on the screen but not able to ouptut to a csv file.
#echo off
" C:\ProgramFiles\MYSQL\MYSQL Workbench 6.3 CE\mysql.exe" mysql -uroot -ppassword -e "select plate form SWP;" > \output.csv
pause
exit
mysql got a feature for this : LOAD DATA INFILE
This will load the content of a query in a file.
Check the doc here :
https://dev.mysql.com/doc/refman/5.7/en/load-data.html
I am moving one database from one computer to another computer.
I have copied the folder from Xampp > Mysql >Data > 'Database named folder' and placed in same location in new computer.
Now I am trying to access the tables of that database from new computer using PHPMYADMIN from browser and I am getting this error :
#1932 - Table 'recoverydata.assignfeedback_editpdf_quick' doesn't exist in engine
Is there any more file that I need to copy? Or what's the solution?
Using Command Line Windows:
Exporting the database
Open up a Windows command prompt.
Change the directory to the following to access the mysqldump utility.
cd \bin
Create a dump of your current mysql database or table (do not include the bracket symbols [ ] in your commands).
Run the mysqldump.exe program using the following arguments:
mysqldump.exe –e –u[username] -p[password] -h[hostname] [database name] > C:\[filename].sql
If you supplied all the arguments properly, the program will connect to your current mysql server and create a dump of your whole database in the directory you specified in your C:\ directory. There is no message that will indicate the dump has been completed, the text cursor will simply move to the next line.
Here is an example of the command line syntax:
Importing The Database :
Go to the directory that the mysql client utility is located.
cd C:\Program Files\MySQL\MySQL Server 5.5\bin
Import the dump of your database or table.
Run the mysql.exe program using the following arguments.
mysql –u[user name] -p[password] -h[hostname] [database name] < C:\[filename].sql
I'm executing on a Centos Linux server this command:
mysql -u root -p mydatabase < dump.sql
I enter the password. It seems that all is ok because I absolutely get no errors, no messages that something happened. But sadly, the file is not imported!
Tryed in different ways:
-Putting the sql file in another location.
-Creating the DB first and than without the DB.
-Avoiding the dbname
-Adding max_allowed_packet=800M in /etc/my.cnf (because the file is 490mb)
-Restarted Mysql. But nothing to do. No errors, no import. I'm stuck and in panic. What to do? ?
If you have already created database then use below steps to import data from .sql file
DataBase to use:
use DataBaseName;
Give the source file path
source /path/to/dump.sql;
Hope this will help
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.
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.