Some one please correct the below syntax to restore the mysql backup file using
command prompt.
"C:\MySQL\MySQL Server 5.7\bin\mysql.exe" -u root -pmypassword source C:/Program Files/Default Company Name/Setup2/Dump20160805.sql
"C:\MySQL\MySQL Server 5.7\bin\mysqldump.exe" -uroot -pmypassword > C:/Program Files/Default Company Name/Setup2/Dump20160805.sql
Related
Can we restore MySQL database from SQL dump file which is stored in Azure Storage as Blob/Fileshare directly without downloading it?
While using below command in powershell/cmd:
& cmd.exe /c "mysql --user=root --password=pass --protocol=tcp --host=dbname.mysql.database.azure.com --user=user#mysql --port=3306 --default-character-set=utf8 < https://storageaccount.blob.core.windows.net/container/azure.sql"
I am getting "The filename, directory name, or volume label syntax is incorrect" error.
There are a little different to do this on Windows.
Create a bat file, contains mysql database backup command text.
Create a task in Windows Task Schedule to execute this bat file.
Then you could config this task as your wish, and do restore.
1: Backup Database.
#ECHO OFF
set filename=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe" -uroot -p123456 -hlocalhost databaseName > C:\Danny\MySql-BackUp\databaseName-%filename%.sql
Format Explain:
mysqldump.exe –e –u[username] -p[password] -h[hostname] [database name] > C:[filename].sql
Run batch file, you will get a sql file contains all database info.
2:Restore database using backup sql.
Get into Mysql root path in CMD, and execute below command:
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql.exe -uroot -p123456 -hlocalhost databaseName < C:\Danny\MySql-BackUp\databaseName-201801311848321.sql
I have created a dump file for my database and now I want to put that
file on my server to get its access. I will copy that .sql file on my
server, but I don't know how to access that dump file using commands.
Assuming you are using command line
cd /path/where/sql/file/is
And then
mysql -u username -p database_name < file.sql
If you don't have the mysql bin in your PATH you might want to run
/path/to/mysql/bin/mysql -u username -p database_name < file.sql
Or temporarily put the file.sql in the mysql bin directory (not recommended)
Another possible scenario is to point to the file in the filesystem like this
mysql -u username -p database_name < /path/where/sql/file/is/file.sql
If you're on windows you might wanna change the forward slashes to backslashes.
If you want to restore MySQL database on remote-server, then very first thing is that, the .sql file is not necessarily present on server.
We can restore the backup right from our development machine(using mysql.exe of local machine), provided that you have MySQL user having MySQL Server remote access.
Use "-h" option while restoring the backup. "-h" implies hostname where MySQL Database Server is present. It can be in local network or on remote server.
mysql -h www.yourserver.com -u username -p database_name < file.sql
Or with IP Address (use actual IP Address of your Database Server)
mysql -h 112.112.112.112 -u username -p database_name < file.sql
And if you do not have remote-access enabled user, then you need to upload .sql file to remote-server and restore it by putting host-name as localhost. Like,
mysql -h localhost -u username -p database_name < file.sql
Hope it helps, thanks.
I have copy of .sql file that contains large data. I saved it from phpmyadmin while I was using WAMP for development. Now I am working with CentOS, and I have transferred the data to my VirtualBox running CentOs already.
So, the problem is not about transferring the file but running the .sql file using shell, so the data can be transferred to the new mysql server.
Does anyone know any commands?
Initially I thought moving this entire directory:
C:\wamp\bin\mysql\mysql5.5.24\data
To my new server environment would be a good idea, but I can't seem to find where the data folder is kepyt in centos-mysql.
whereis mysql gives mysql: /usr/bin/mysql /usr/lib/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
I have checked all this folders to find the data folder but to no avail.
if you created the .sql file with mysqldump or if it is otherwise a legal mysql script containing sql commands you can simply pipe this contents to your centOs mysql instance:
$ mysql -uroot -p dbname < dump.sql
where dbname is the name of your database and dump.sql your .sql file.
Follow these steps:
1- In your Windows Environment, from command line(CMD), go to the folder:
cd "C:\wamp\bin\mysql\mysql5.5.24\bin
2- Run: mysqldump -uroot -pYourPassword DataBaseName > myBackup.sql
3- On your centOs machine, open a terminal:
mysql -uroot -p
4- In mysql console:
create database DataBaseName;
exit;
5- Transfer the myBackup from your Windows System, to centOS, open a terminal in
the same directory where myBackup.sql lives:
mysql -uroot -p DataBaseName < myBackup.sql
I'm currently trying to make a copy of a site to run locally, and i'm having some difficulty in downloading a dump of the mySQL database using PhpMyAdmin. (In that it doesn't work). I was wondering (and I suspect) if there is an sql command I can execute that would dump out the database to a location that I can download it via FTP.
I've found the following:
mysqldump --opt --user=root --password password > /home/backup/db.sql
but the page says that this will only run via shell, and I don't have shel access to the server. Can anyone help?
mysqldump -u root -p -T/path/ database
Simple Three steps Export mysql DB
**step1 :** run windows command prompt
**step2 :** make where yours wamp mysql stored directory ex E:\wamp\bin\mysql\mysql5.5.24\bin
**step 3 :**
E:\wamp\bin\mysql\mysql5.5.24\bin> mysqldump -u UserName -p PassWord dbname >c:\dbname.sql
PERFORM MySQL DATABASE DUMP:
Having registered mysql.exe in the Paths of Environment Variables (On
Windows Os)
Open windows console
Type the following Query:
mysqldump [Your database Name] -u root -p > C:/[Your Destination Directory ]/[ new Backup Database Name.sql ]
You will be prompted for a database user password
Enter Password:*******
when the dump is over...the directory will go back to the current
user session in Windows console
For this to work well, replace all parameters in square braces "[ ]" with your own values without the square braces
Open the Command prompt from MySQL bin folder (Make sure you have Read/Write Access)
Use the below mysqldump command
mysqldump -h [hostname] -u [username] -p [your database] > [your destination path][your filename.extn]
Ex: mysqldump -h localhost -u root -p test_DB > D:\MySQL\Dumps\test_file.sql
***WARNING : In case, if your custom path has any spaces in between, the above query will throw an error.
Invalid Path Description
To avoid Invalid Path Description, Give your path in double-quotes.
Ex : mysqldump -h localhost -u root -p test_DB > D:\MySQL\"Dumps from ABC"\test_file.sql
What are you looking for is Sypex Dumper 2. It exports (backups) your database directly to disk, so you can download the backup via ftp. It is written on php, supports large databases and has a very nice interface.
You can go to the directory where you want store the file, then execute de mysqldump command.
~/Desktop$ sudo /Applications/XAMPP/xamppfiles/bin/mysqldump -u root -p publicaciones > publicaciones.sql
PD. Use sudo to grant full permissions.
PD. If you have your PATH setup, don`t need use the full route to your MySql commands.