Since MySQL 8 the column-statistics flag is enabled by default.
So if you try to dump some tables with MySQL Workbench 8.0.12, you get this error message:
14:50:22 Dumping db (table_name)
Running: mysqldump.exe --defaults-file="c:\users\username\appdata\local\temp\tmpvu0mxn.cnf" --user=db_user --host=db_host --protocol=tcp --port=1337 --default-character-set=utf8 --skip-triggers "db_name" "table_name"
mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'db_name' AND TABLE_NAME = 'table_name';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)
Operation failed with exitcode 2
14:50:24 Export of C:\path\to\my\dump has finished with 1 errors
Is there any way in MySQL (Workbench) 8 to disable column-statistics permanently?
Workaround 1
An annoying workaround is doing it by hand via:
mysqldump --column-statistics=0 --host=...
Workaround 2
rename mysqldump
create a shell script (or batch on Windows)
call the renamed mysqldump with the --column-statistics=0 argument within this script
save it as mysqldump
Workaround 3
download MySQL 5.7
extract mysqldump
use this mysqldump
For example in MySQL Workbench: Edit / Preferences... / Administration / Path to mysqldump Tool
Thanks in advance!
Workaround for me:
Create file named mysqldump.cmd with contents:
#echo off
"c:\Program Files\MySQL\MySQL Workbench 8.0 CE\mysqldump.exe" %* --column-statistics=0
(replace path to mysqldump.exe if necessary)
Open MySQL Workbench and go to Edit > Preferences > Administration, change path to mysqldump tool and point it to mysqldump.cmd
Easiest Work Around
When using Mysql Workbench 8.0
Open the "Data Export" Tab
Click Advanced Options
Under the Other heading, set column statistics to 0
Export again
Best of luck!
I have download the version 8.0.16, still the same issue.
At data export advanced options I didn't saw any option about "statistics"!
I have add at my.ini at
[mysqldump]
quick
max_allowed_packet = 16M
column-statistics=0
Doesn't solve the issue
I have been googling but I couldn't find the solution. I find a of companions who are strugling with this but not anyone with the solution at least for me.
At the end I have changed at MySQL Workbench file c:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\wb_admin_export.py:
skip_column_statistics = True #if get_mysqldump_version() > Version(8, 0, 2) and self.owner.ctrl_be.target_version < Version(8, 0, 0) else False
I have made comment of
if get_mysqldump...
I know this is not the way, but I can't find now another better solution. For me is this at least weird and strange. If anyone has a better solution let me know!
P.S. Restart Workbench after change has been made
The idea is this: each server version has a dedicated mysqldump version. Not ideal and certainly not very backwards compatible, but that's the situation. MySQL Workbench can only include one mysqldump binary, so the latest one is used. The approach to download the MySQL 5.7 zip and use mysqldump from there is a good workaround without many side effects. You only have to be careful which server you dump with which dump version.
If you like to have that column stat flag automatically applied by MySQL Workbench please file a bug report at https://bugs.mysql.com.
Update
Meanwhile a bug report has been created for this issue: https://bugs.mysql.com/bug.php?id=91640
WINDOWS USERS
I have MySQL Workbench 8.0CE and Xampp v3.2.3 and this worked for me:
Open xampp, and open mysql config > my.ini // add: column-statistics = 0 so:
[mysqldump]
quick
max_allowed_packet = 16M
column-statistics = 0
Save and close, reboot xampp mysql server. (just in case)
in Workbench:
Edit > Preferences > Administration
In Mysqldump route put your mysqldump route of xampp, in my case:
C:\xampp\mysql\bin\mysqldump.exe
This worked for me!
There may be another workaround if you are running an OS that supports mysqldump (i.e. Linux). Set the path to the mysqldump binary in the preferences and include the --column-statistics=0 argument in the path, in:
Edit >> Preferences >> Administration >> path to MysqlDump Tool
From Mysql-workbench version 8.0.14 you don't have the option to disable column-statistics.
But you have an option to do it by enabling delete-master-logs:
https://stackoverflow.com/a/64855306/10747412
Download the last version of Mysql Workbench 8.0.16 and no more problems.
https://dev.mysql.com/downloads/workbench/
No option to check !
Open MySQL Workbench Preferences and choose Path to mysqldump Tool accordiing to your xampp / mysql server path
MySQL Workbench Edit > Preferences > Administration
C:\xampp\mysql\bin\mysqldump.exe
that's it
I am using Ubuntu 16.04, MySql Workbench 6.3.6, MySql 8.0.25, MySqlDump 8.0.25.
My workaround is as follows:
Open /usr/lib/mysql-workbench/modules/wb_admin_export.py
Replace
s = re.match(".*Distrib ([\d.a-z]+).*", output)
with
s = re.match(".*mysqldump Ver ([\d.]+).*", output)
Replace
cmd = subprocess.list2cmdline(args)
with
args.append("--column-statistics=0")
cmd = subprocess.list2cmdline(args)
Linux users
Same idea as the other answer above on Windows, here is a way to globally change the mysql settings on Linux so that you do not need to write mysqldump --column-statistics=0 anymore.
Quote from Server Fault Stack Exchange at mysqldump throws: Unknown table 'COLUMN_STATISTICS' in information_schema (1109), highly upvoted there:
To disable column statistics by default, you can add
[mysqldump]
column-statistics=0
to a MySQL config file. Go to /etc/my.cnf, ~/.my.cnf, or directly
to /etc/mysql/mysql.cnf.
I recommend changing it directly in the /etc/mysql/mysql.cnf.
I fixed this by amending the MySQL Workbench config file wb_admin_export.py.
See my answer here.
[![Export From DBEAVER with extra command][1]][1]
For me, I just added an extra command and it worked for me!
[1]: https://i.stack.imgur.com/9iBvO.png
Mac user:
/Applications/MySQLWorkbench.app/Contents/Resources/plugins
Update file wb_admin_export.py to skip_column_statistics in all cases.
skip_column_statistics = True # if get_mysqldump_version() > Version(8, 0, 2) and self.owner.ctrl_be.target_version < Version(8, 0, 0) else False
Related
I am a linux beginner, especially ubuntu. I want to manage the mysql database installed on my Ubuntu web server by using Putty. But the MySQL syntax that I run always fails. Example syntax:
mysql -u root -p
All failed messages are the same for any syntax:
mysql: unknown variable 'bind-address = 0.0.0.0'
I don't know whether to run the Mysql syntax on Ubuntu I need to go to a certain Folder/Path, like in windows if I want to run the mysql syntax I need to go to the path where MySql is installed, for example C:/xampp/mysql/bin and then run the syntax mysql -u root -p.
is there anything I miss? and what should i do? please help, thank you.
Option 1: A typo in a title
Have a look in your my.cnf file.
Maybe you have a typo: There should be [mysqld] instead of [mysql] section
[mysqld] bind-address=0.0.0.0
OR
[mysqld]
bind-address=0.0.0.0
Source
Option 2: Is it Maria DB?
Are you sure you are using MySQL ?
This looks like a MariaDB error.
Try to remove the bind-address from your mysql.cnf file.
Option 3: Check for any whites-pace?
Try editing the file and using show all characters in your editor (e.g. Notepad Plus Plus). Maybe there are whitespace characters ( such as spaces ) causing problems.
A. First things first:
Mr. Google hasn't helped me to found any reply to my question
above
Yes, I have read a solution to the opposite question here
How to upgrade MySQL to MariaDB in XAMPP in 5 minutes on Windows
(and it hasn't helped me: MySQL simply doesn't start)
I don't expect replies like 'MariaDB is better, - stop your silly
exercises'.
B. I am working with MySQL Workbench and because of that don't want to face any incompatibilities either now or in future.
C. Can someone share their experience (if any) in solving this problem?
Running XAMPP with MySQL
Here are exact step by step instructions for truly integrating MySQL into XAMPP on Windows. This has been successfully tested with Windows 10 and XAMPP 7.3.11 for both MySQL 8.0.18 and 5.7.28.
Stop MySQL (which actually is MariaDB) in the XAMPP Control Panel.
Download the MySQL community server as zip archive (Windows 64 bit version)
Rename C:\xampp\mysql to C:\xampp\mariadb
Extract the downloaded zip archive to C:\xampp\mysql. Make sure you extract the folder level which has the subfolders bin, include, lib etc.
Copy C:\xampp\mariadb\bin\my.ini to C:\xampp\mysql\bin
Open C:\xampp\mysql\bin\my.ini in an editor and comment out the line starting with key_buffer= in the [mysqld] section.
Open a command prompt and run the following commands:
For MySQL 8.0.18:
cd C:\xampp\mysql
bin\mysqld --initialize-insecure
start /b bin\mysqld
bin\mysql -u root
CREATE USER pma#localhost;
SOURCE C:/xampp/phpMyAdmin/sql/create_tables.sql;
GRANT SELECT, INSERT, DELETE, UPDATE, ALTER ON phpmyadmin.* TO pma#localhost;
ALTER USER root#localhost IDENTIFIED WITH mysql_native_password BY '';
ALTER USER pma#localhost IDENTIFIED WITH mysql_native_password BY '';
\q
bin\mysqladmin -u root shutdown
For MySQL 5.7.28:
cd C:\xampp\mysql
bin\mysqld --initialize-insecure --log_syslog=0
start /b bin\mysqld --log_syslog=0
bin\mysql -u root
CREATE USER pma#localhost;
SOURCE C:/xampp/phpMyAdmin/sql/create_tables.sql;
GRANT SELECT, INSERT, DELETE, UPDATE, ALTER ON phpmyadmin.* TO pma#localhost;
\q
bin\mysqladmin -u root shutdown
Start Apache and MySQL in the XAMPP Control Panel.
Go to http://localhost/phpmyadmin and verify that your database server is now reported as MySQL Community Server.
You can use the following way.
Stop MariaDB in Xampp which show as mysql running...
Download the installer for windows mysql Installer
Follow the instruction.
Now start Apache2 and clear cookie in your browser. Now you can see phpmyadmin and workbench showing Server type: MySQL
If you want to stick to MariaDB then you can use sqlyog also.
Hope it answer your question
You have to do little adjustment with xampp in order to use MySQL instead of MariaDB . I just did following and its worked , i think it may helpful to others also.
Download and install mysql installer.
2.stop xampp and rename the mysql folder inside the xampp directory(may be its not necessary! )
3.just start Apache only from xampp control panel . No need to start mysql.
4.Last step . Make sure your running MySQL in your system . That's it ..
Check php admin panel there you can see Server type: MySQL instead of MariaDB ...
Thanks..
I just upgraded XAMPP because of PHP 7. I am also using mysql workbench. I want to be as close to production as I can, but my webhoster supports only mysql. These where my reasons to switch back from mariadb to mysql
I followed these steps: (also max 5min)
https://gist.github.com/odan/c799417460470c3776ffa8adce57eece
I just installed a new Windows 7 Professional machine with MySQL 5.6.22. When trying to run the mysqldump command, I get the following:
E:>mysqldump -u root -p world > world.sql
mysqldump: unknown option '--no-beep'
Mysqldump works fine on my other machines running 5.16.15 and 5.5.xx.
Unfortunately, the msi installer for MySQL 5.6.15 will not work as some packages cannot be found. Oracle, it seems, will not support previous editions of 5.6.
On top of that, the MySQL installer for 5.6.23 only installs 5.6.22 in a round about way. The MSI installer has issues.
Can anyone shed light on mysqldump not working in 5.6.22?
Thanks!
I think you need to run the mysqldump command from the path it is installed, first cd into the folder and then run the command like this
C:\MySQL\MySQL Server 5.6\bin>mysqldump -u root -p -B database>name_of_backup_file.sql
I had the same issue. Search your active my.ini for the [client] section. Likely you will find the following:
[client]
no-beep
Comment or delete no-beep. It solves the 'no-beep' issue (now I have a new annoying error, hooray!). Be carefully checking whats your active my.ini because you might have some on different places.
Edit: Now, as I can call mysqldump w/o error, option --help tells me the follwing:
Default options are read from the following files in the given order:
C:\Windows\my.ini C:\Windows\my.cnf C:\my.ini C:\my.cnf [Your Server DIR]\my.ini [Your Server DIR]\my.cnf
I was trying to create a dump file from my MySQL database, but when I try it always gives me this error
Operation failed with exitcode 2
16:06:07 Dumping proactivetraindb (userstate)
Running: mysqldump.exe --defaults-extra-file="h:\docume~1\anarita\locals~1\temp\tmpde5rwy.cnf" --user=root --max_allowed_packet=1G --host=localhost --port=3306 --default-character-set=utf8 "proactivetraindb" "userstate"
mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_QUOTE_SHOW_CREATE=1' at line 1 (1064)
The version of MySQl is 5.6.10 but the version of MySQLDump is 5.5.16
Does someone know how to solve this?
As outlined by a previous answer, but just to clarify further: This is for MySQL in Windows.
I was having the exact same issue while trying to dump data out of a table on a local test server, and based on the previous answer, this is how I did it.
Find your mysql original download folder, and look in the /bin folder, there should be a mysqldump.exe.
Go into Workbench Preferences: Edit -> Preferences -> Administrator -> Path to mysqldump Tool, and enter in the path to the mysqldump.exe that you found.
Save by pressing "OK" and restarting Workbench.
Open up terminal, but typing in cmd in the Search area of the start menu (Windows 7), and find the sql folder you found in step 1, and cd into bin. It should look like C:\...\bin>. Here, type in mysqldump -t -u [username] -p [database name] [tablename]. This should dump the data from the [tablename] table into the dump folder as designated in Workbench.
Hope this helps!
I had the same error in MySQL Workbench.
Find out where is the mysqldump tools provided by your install of MySQL 5.6. On my mac it was at "usr/local/mysql-5.6.10-osx10.7-x86_64/bin/mysqldump".
Then I set up this path in MySQL Workbench/Preferences/Administrator/Path to mysqldump Tool
Give MySQL Workbench a restart.
It should work.
The reason for this is that MySQL 5.6 has removed support for "SET OPTION" and your mysql client tools are probably on older version. Most likely 5.5 or 5.1. There is more info about this issue on MySQL bugs website.
The quickest solution is to update your mysql client tools to 5.6 and your problem will be solved. If you are on Linux platform, here is a solution that worked great for me:
http://www.markomedia.com.au/mysqldump-mysql-5-6-problem-solved/
You must use mysqldump 5.6.x to be able to dump mysql 5.6 database, because MySQL 5.6 discontinued and removed support for SET OPTION syntax.
Under 32/64bit Windows you must do:
1.1. (32bit win) Download Windows (x86, 32-bit), ZIP Archive 5.6.19 212.3M http://dev.mysql.com/downloads/mysql/ (direct link http://dev.mysql.com/downloads/file.php?id=452188)
1.2. (64bit win) Download Windows (x86, 64-bit), ZIP Archive 5.6.19 217.2M http://dev.mysql.com/downloads/mysql/ (direct link http://dev.mysql.com/downloads/file.php?id=452189)
2. Extract mysqldump.exe from just downloaded file mysql-5.6.19-win32(64).zip (from /mysql-5.6.19-win32(64)/bin/mysqldump.exe)
3. Replace this just extracted file with your already installed mysqldump.exe file (instalation dir/mysql/bin/mysqldump.exe)
Using Windows 7, a far easier solution for me was to find mysqldump.exe from; C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe
copy it and then replace the MySQL workbench mysqldump.exe which is located in the root of workbench C:\Program Files\MySQL\MySQL Workbench CE 5.2.47\mysqldump.exe
Restart MySQL workbench and all should work fine.
You are probably using Amazon RDS, right?
You can just get the newer version of mysqldump, v5.6 and use it instead.
Download the portable zip here and extract just the mysql\mysqldump.exe there.
http://sourceforge.net/projects/xampp/files/XAMPP%20Windows/1.8.3/
I tried it just now and it worked fine for me.
If you are using Window 10. Your Mysql server would have been installed in C:\Program Files\MySQL directory and rest all components are installed in C:\Program Files (x86)\MySQL.
Go to MySql Workbench>Edit>Preferences. A window will open, click the Administrator tab and mention the path of your mysqldump.exe (which is present in C:\Program Files\MySQL). Restart your workbench.
Thanks, Happy coding!!
In Workbench look for Preferences: Edit -> Preferences -> Administrator -> Path to the mysqldump Tool. Browse your MySQL folder inside the bin folder and look for mysqldump.exe.
I had this problem on the Amazon EC2 acessing a RDS Mysql 5.6 database. I just ran
sudo apt-get upgrade
It didn't update mysql client to 5.6, but mysqldump now is working fine.
For Mac it depends on your installation.
If you used a dmg file to install it, you need to find the bin directory.
mine was under /usr/local/mysql/bin
You will find mysqldump file under this folder.
Now provide this location in your
Preferences -> Administrator -> Path to mysqldump Tool as /usr/local/mysql/bin/mysqldump
You should be good to export now.
If you are on Linux, update mysql-client to latest version. On Ubuntu:
sudo apt-get upgrade mysql-client
did the job for me.
Setting up mysql-client-5.5 (5.5.43-0ubuntu0.12.04.1) ...
Mine got updated to 5.5 and mysqldump now works for me. This is on Amazon RDS with MySQL 5.6.x
If you're on a linux machine, this is provided by the mysql-client package. Installing that fixed the problem for me.
For compatibility, I needed MySQL 5.6.41 on my Windows 10 machine, so I used the 5.6.41 MySQL installer to install "All" (My Workbench, MySQL, connectors, etc).
Even though I used the installer for version 5.6.41, it installed Workbench 8.0, as well as version 8.0 of the various connectors, etc.
So of course, I got a similar error.
There seems to be no easy way to force lower version of MySQL Workbench to be installed instead (On my previous machine, before workbench 8.0, did NOT have this conflict when installed).
Solution that worked for me:
Find the version of mysqldump.exe that matches the version of MySQL you're using:
From Windows Explorer, I searched my machine for all versions of mysqldump.exe
Right-clicked each mysqldump.exe it found -> Properties -> Details tab.
Found the version 5.6.41 (matching the MySQL version I'm running)
Clicked back to the General tab, to see the folder path that that version of mysqldump.exe was installed in
C:\Program Files\MySQL\MySQL Server 5.6\bin, in my case
(version 8.0 was installed in C:\Program Files\MySQL\MySQL Workbench 8.0 CE)
Now open MySQL Workbench..
Edit -> Preferences -> Administration -> Path to mysqldump Tool
Paste in the file path for the appropriate version of mysqldump.exe (including the file name!)
Click OK
Restart MySQL Workbench
This worked for me. However, I have no idea how to make this work if you have two versions of MySQL on your machine, say MySQL 5.6 and 5.7, or 8.0.
So when I upgrade (any/some/all of) my cloud servers to version 5.7, this looks to be another challenge to overcome. Since Workbench only allows a single mysqldump.exe file, to be used no matter which version of my local MySQL server is running... Or perhaps manually change the path location, each time open a connection that uses the Port to the other MySQL version (and remember to change it back after?).
For this reason, I Removed MySQL 5.7 completely, and will hence keep all cloud (and my local) servers at 5.6 for the time being - a Project for another day.
For Ubuntu users to save your time, mysqldump is in "mysql-community-client_5.7.26-1ubuntu16.04_i386.deb " package
I just had the same problem and I put a couple of different answers together.
The pro for me was, that I could switch easily between 5.6, 8, ... without having to up/downgrade ubuntu dependencies each time.
The easiest way for me on Ubuntu was to just download the 5.6 (or 5.7, whatever you want) mysqldump binary and change that in workbench.
Everything went well after that:
go to https://downloads.mysql.com/archives/community/ and download the correct version you want (for me: 5.6.47 for 64x)
Unpack the archive somewhere, you can find later
Change the mysqldump binary in mysql workbench: Edit -> Preferences -> Administrator -> "Path to mysqldump Tool" to {{YOUR_UNPACKED_FOLDER}}/bin/mysqldump
Save it with Ok
Now you should be able to just export and it will use mysqldump 5.x.
I have Mysql 5.6.12 version. SET SQL_QUOTE_SHOW_CREATE=1 is working fine in my machine.
now i am able to take a dump of sql.
mysql> SET SQL_QUOTE_SHOW_CREATE=1; Query OK, 0 rows affected (0.00
sec)
worked for me.
I have a database called nitm. I haven't created any tables there. But I have a SQL file which contains all the necessary data for the database. The file is nitm.sql which is in C:\ drive. This file has size of about 103 MB. I am using wamp server.
I have used the following syntax in MySQL console to import the file:
mysql>c:/nitm.sql;
But this didn't work.
From the mysql console:
mysql> use DATABASE_NAME;
mysql> source path/to/file.sql;
make sure there is no slash before path if you are referring to a relative path... it took me a while to realize that! lol
Finally, i solved the problem. I placed the `nitm.sql` file in `bin` file of the `mysql` folder and used the following syntax.
C:\wamp\bin\mysql\mysql5.0.51b\bin>mysql -u root nitm < nitm.sql
And this worked.
If you are using wamp you can try this. Just type use your_Database_name first.
Click your wamp server icon then look for MYSQL > MSQL Console then run it.
If you dont have password, just hit enter and type :
mysql> use database_name;
mysql> source location_of_your_file;
If you have password, you will promt to enter a password. Enter you password first then type:
mysql> use database_name;
mysql> source location_of_your_file;
location_of_your_file should look like C:\mydb.sql
so the commend is mysql>source C:\mydb.sql;
This kind of importing sql dump is very helpful for BIG SQL FILE.
I copied my file mydb.sq to directory C: .It should be capital C: in order to run
and that's it.
In windows, if the above suggestion gives you an error (file not found or unknown db) you may want to double the forward slashes:
In the mysql console:
mysql> use DATABASE_NAME;
mysql> source C://path//to//file.sql;
Ok so, I'm using Linux but I think this holds true for Windows too.
You can do this either directly from the command prompt
> mysql -u <user name> -p<password> <database name> < sqlfilename.sql
Or from within the mysql prompt, you can use:
mysql>source sqlfilename.sql
But both these approaches have their own benefits in the results they display.
In the first approach, the script exits as soon as it encounters an error. And the better part, is that it tells you the exact line number in the source file where the error occurred. However, it ONLY displays errors. If it didn't encounter any errors, the scripts displays NOTHING. Which can be a little unnerving. Because you're most often running a script with a whole pile of commands.
Now second approach (from within the mysql prompt) has the benefit that it displays a message for every different MySQL command in the script. If it encounters errors, it displays the mysql error message but continues on through the scripts. This can be good, because you can then go back and fix all the errors before you run the script again. The downside is that it does NOT display the line numbers in the script where the errors were encountered. This can be a bit of a pain. But the error messages are as descriptive so you could probably figure out where the problem is.
I, for one, prefer the directly-from-OS-command line approach.
If you are using xampp
C:\xampp\mysql\bin\mysql -uroot -p nitm < nitm.sql
You are almost there
use
mysql> \. c:/nitm.sql;
You may also access help by
mysql> \?
For localhost on XAMPP. Open a cmd window and type
cd C:\xampp\mysql\bin
mysql.exe -u root -p
Attention! No semi-colon after -p
Enter your password and type
use database_name;
to select the database you need.
Check if your table is there
show tables;
Import from your sql file
source sqlfile.sql;
I have put my file on C:\xampp\mysql\bin location in order to don't mix up with locations of sql file.
Try:
mysql -u username -p database_name < file.sql
Check MySQL Options.
Note: It is better to use the full path of the SQL file file.sql.
Don't forget to use
charset utf8
If your sql file is in utf-8 :)
So you need to do:
cmd.exe
mysql -u root
mysql> charset utf8
mysql> use mydbname
mysql> source C:\myfolder\myfile.sql
Good luck ))
In Linux I navigated to the directory containing the .sql file before starting mysql. The system cursor is now in the same location as the file and you won't need a path. Use source myData.sql where my date is replaced with the name of your file.
cd whatever directory
mysql - p
connect targetDB
source myData.sql
Done
from the command line (cmd.exe, not from within mysql shell) try something like:
type c:/nite.sql | mysql -uuser -ppassword dbname
Does your dump contain features that are not supported in your version of MySQL? You can also try to remove the starting (and ending) MySQL commented SET-statements.
I don't know if your dump comes from a Linux version of MySQL (line endings)?
I have installed my wamp server in D: drive so u have to go to the following path from ur command line->(and if u have installed ur wamp in c: drive then just replace the d: wtih c: here)
D:\>cd wamp
D:\wamp>cd bin
D:\wamp\bin>cd mysql
D:\wamp\bin\mysql>cd mysql5.5.8 (whatever ur verserion will be displayed here use keyboard Tab button)
D:\wamp\bin\mysql\mysql5.5.8>cd bin
D:\wamp\bin\mysql\mysql5.5.8\bin>mysql -u root -p password db_name < "d:\backupfile.sql"
here root is user of my phpmyadmin
password is the password for phpmyadmin so if u haven't set any password for root just nothing type at that place,
db_name is the database (for which database u r taking the backup)
,backupfile.sql is the file from which u want ur backup of ur database and u can also change the backup file location(d:\backupfile.sql) from to any other place on your computer
mysql>c:/nitm.sql;
That would write the output of the mysql command to 'nitm.sql;' (What's the ';' supposed to do?) Assuming you've got a copy of the original file (before you overwrote it) then:
mysql < c:/nitm.sql
Export Particular DataBases
djimi:> mysqldump --user=root --host=localhost --port=3306 --password=test -B CCR KIT >ccr_kit_local.sql
this will export CCR and KIT databases...
Import All Exported DB to Particular Mysql Instance (You have to be where your dump file is)
djimi:> mysql --user=root --host=localhost --port=3306 --password=test < ccr_kit_local.sql
In Windows OS the following commands works for me.
mysql>Use <DatabaseName>
mysql>SOURCE C:/data/ScriptFile.sql;
No single quotes or double quotes around file name. Path would contain '/' instead of '\'.
For those of you struggling with getting this done trying every possible answer you can find on SO. Here's what worked for me on a VPS running Windows 2012 R2 :
Place your sql file wherever the bin is for me it is located at C:\Program Files\MySQL\MySQL Server 8.0\bin
Open windows command prompt (cmd)
Run C:\Program Files\MySQL\MySQL Server 8.0\bin > mysql -u [username] -p
Enter your password
Run command use [database_name];
Import your file with command source C://Program Files//MySQL//MySQL Server 8.0//bin//mydatabasename.sql
It did it for me as everything else had failed. It might help you too.