I have a Win7 machine running PHP/MySQL/Apache and I have MySQL Administrator, MySQL Manager for MySQL installed along with a few other tools like Toad MySQL 6.0...
I was looking for a solution for some utf-8 issues I've been having and the majority of solutions (ie this one) say to run a set of commands such as mysqldump etc... But HOW do I run a command on a windows machine? I've tried executing it as an SQL script, running from the Windows Run command like
"C:\Program Files\MySQL\MySQL Server 5.1\bin\" mysqldump MY_DB -uroot --opt --quote-names --skip-set-charset --default-character-set=latin1 >c:\MY_DB_latin1.sql
but without luck. Any suggestions would be very helpful.
The problem is the space between "C:\Program Files\MySQL\MySQL Server 5.1\bin\" and mysqldump. This should read "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqldump".
Adding the .exe is optional: "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqldump.exe".
If you want to execute MySQL commands instead of dumping the database you should use mysql.exe: "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.exe". Use the -? option to get an overview of the command line options.
you have a space before mysqldump which is not required.
Also it should be mysqldump.exe
Win+R -> cmd -> OK
is a Windows command line.
Here you can type (assuming that C:\Program Files\MySQL\MySQL Server 5.1 is a correct path to your MySQL directory and MY_DB is your database name):
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqldump.exe" MY_DB -uroot --opt --quote-names --skip-set-charset --default-character-set=latin1 >c:\MY_DB_latin1.sql
Here, you'll be able to see the output (most likely you will need -uroot -p, because your root account is password-protected, isn't it?).
If you'd like to paste a command, right-click and select "Paste" - Ctrl-V won't work here.
Related
I have a simple BAT file that I want to run at times to take backups of two local development MySQL databases.
The file name should be "testdb1-Fri 6/6/2018 194233.sql" for example. However, my BAT script is making mysqldump look for a table called 6/6/2018 somehow? Script below, and screenshot of error.
#ECHO OFF
set filename=%date:~0,4%%date:~5,2%%date:~8,2%%date:~10,4% %time:~0,2%%time:~3,2%%time:~6,2%
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe" -u root -proot -hlocalhost cadsys > C:\temp\testdb1-%filename%.sql
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe" -u root -proot -hlocalhost comm1 > C:\temp\testdb-%filename%.sql
pause
cls
exit
Any pointers?
Add quotes around the suggested filename, the spaces within the filename are interpreted by mysqldump as seperate commands
set filename="%date:~0,4%%date:~5,2%%date:~8,2%%date:~10,4% %time:~0,2%%time:~3,2%%time:~6,2%"
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
Friends, I have kept on tying and trying to restore a mysql database from a backup I created with mysqldump. I have been using this code (run in a command prompt Win XP and Win 7)
"C:\Program Files\MySQL\MySQL Server 5.5\mysql --user=root --password=password --host= localhost --port= 3306 --database=dbname < C:/Backup/dbname.sql"
I get "The filename, directory name, or volume lable syntax is incorrect" error messsage. I have googled for this error to no avail as to do with mysql.
*My mysql server is up and running with no problem. (Even the mysqldump command works)
*Problem is the same even if I open the command prompt from C:\Program Files\MySQL\MySQL Server 5.5\mysql
*I have tried to remove "", did not help.
*I have tried to use back slashes () instead of (/), did not help.
For this one, I will really appreciate any help. What is the problem here? what is this filename,directory name.... syntax error?
Thank you.
I think this is because you have quoted the whole command when you only need to quote the program name because there is a space in the path
Also the path for the backup file looks like it has "/" in place of "\"
Should be more like (assuming the options are correct:
"C:\Program Files\MySQL\MySQL Server 5.5\mysql.exe" --user=root --password=password --host= localhost --port=3306 --database=dbname < C:\Backup\dbname.sql
You can quit the file you're trying to execute from the command line and instead log in in MySQL and once inside do:
source C:/Backup/dbname.sql
Open Command Prompt and type this
cd C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin
Press Enter
or,
Directly open this directory "C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin" and Press LEFT SHIFT KEY from keyboard and RIGHT CLICK on the Directory Window.
Type this
mysql -u root -p12345 -h localhost ""DATABASE_NAME"" < e:\tmp.sql
It will work 100% correctly
Hi I have installed MySQL from oracle website, but did not get a "MySQL Command Line" option under MySQL in Programs menu.
So I looked up on this site how to execute sql queries from DOS command prompt.
I found an answer on this site that advised to type in something like: sql root u- p- etc. but this does not work.
Can anyone advise me the syntax to use to go into sql from DOS, or direct me to the answer described above (I cannot locate it)
I use Windows 7 and downloaded the ODBC driver, too.
Many thanks.
Unless MySQL's bin directory is in your PATH variable, you will need to either be in the directory, or write an absolute path to it to execute.
Try something like this (depending on your installation):
cd "C:\Program Files\MySQL\MySQL Server 5.5\bin"
mysql -uroot
Alternatively, you could type this directly:
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe" -uroot
cd/
cd wamp
cd bin
cd mysql
cd mysql5.0.51b
#################################
note use your own version of mysql, mine is 5.0.51b
########################################
cd bin
mysql -h localhost -u root -p
////////////////////////////////
note -p that is if u use a password
////////////////////////////////////////
after this line of codes you have this
welcome note telling you the server version of mysql and your connection id
If you navigate to the bin directory of the program you just installed then type "mysql.exe"
Have a look at this guide if you get stuck with the commands
Determine the path of your MySQL installation, and add it to PATH environment variable.
SET PATH=%PATH%;C:\MySQL\bin
The above example assumes MySQL to be installed in C:\MySQL directory.
Once path is set, then you can directly execute
mysql -u root
Which logs into MySQL as root user. The -p flag can be used if password is required
It is required to execute SET PATH every time, hence you may make a batch file.
I have WampServer 2.0 that is installed on Windows on my laptop.
I'm running on it an application that I wrote. The application is working with MySQL database.
I would like to make backups of this database periodically.
How this can be done ?
How could I define cron on Windows ?
The rough equivalent of crontab -e for Windows is the at command, as in:
at 22:00 /every:M,T,W,Th,F C:\path\to\mysql\bin\mysqldump.exe ...
Running the at command by itself lists the tasks you've created using at.
The mysqldump documentation is here.
The most popular way to backup MySQL database is to use mysqldump:
Open a Windows command line.
Specify the directory to mysqldump utility
cd "C:\Program Files\MySQL\MySQL Server 5.7\bin"
Create a dump of your MySQL database.
mysqldump.exe --user=YourUserName --password=YourPassword --host=localhost --port=3306 --result-file="Pathdump.sql" --databases "DatabaseName"
Also, there are a lot of third-party tools, which can perform MySQL backups automatically on a regular basis.
You could use a bash script.
#!/bin/sh
mysqldump -uroot -ppwd --opt db1 > /sqldata/db1.sql
mysqldump -uroot -ppwd --opt db2 > /sqldata/db2.sql
cd /sqldata/
tar -zcvf sqldata.tgz *.sql
cd /scripts/
perl emailsql.pl
http://paulbradley.tv/38/