MySQL importing issue - mysql

I have MySQL server (version - 5.6.35),lot of database are running here and every day am taking full backup using script,
mysqldump --force --opt --user=$USER --password=$PASSWORD --single-transaction --databases $db > $OUTPUT/date +%Y%m%d.$db.sq
backup is done correctly and its size also seems correct only , but when am trying to restore a single DB nothing is happen . nothing is importing and not getting any error , same time some database can import correctly .
Any one can suggest what is issue and how to resolve .

Here's how you bring it back:
Go into MySQL and do CREATE DATABASE databasename ; You should give it the same name it had before it was backed up.
At a MySQL prompt type source /path/to/OUTPUTdate2017Oct13.db.sq ;
I have only done it from within Linux and do the backup in a similar way to you. Not sure if it works the same from Windows, good luck..

Related

Foolproof methods for mysql -> mysql migration

I've been migrating ddbb (a few GB size) in mySQL workbench 6.1, from one mySQL server to another mySQL. Never having done this before I thought it was 99% reliable. Instead, 2 out of 3 tries have failed.
My ddbb dont have complex features (triggers, SP & functions,...). The errors, though, are difficult to interpret, almost always about tables failing to export, reason unknown. There might be occasionally a duplicated key index in source, but that shouldn't prevent an export from happening?
I've tried all the different methods available in the interface:
1) Server > Data Export > Data Import
2) Migration wizard
3) Schema transfer wizard
4) Reverse engineer
but no real difference.
Also, all methods seem variants of the same, do these menu options rely on the same procedure internally, how really different are they?
My questions are generic:
1) Is there a foolproof method, relaxed about errors, e.g. is
mysqldbcopy from myQL utilities much better that workbench wizards?
2) Does mySQL wizards configuration make any difference (e.g. a checkbox that causes errors by being too demanding if the source db has a problem) I just want to transfer the db, not perfection in the target server. I've switched SSL=NO, but still not working.
3) What is the single most important cause of errors in migration, e.g. server overloaded, enough memory, table structure?
Thanks in advance,
There might be occasionally a duplicated key index in source, but that shouldn't prevent an export from happening?
Yeah, It shouldn't prevent export operation.
I've tried all the different methods available in the interface:
All interface you have used might have some timeout configured so it don't really execute fully as your database is BIG.
So how to migrate MySQL database from one server to another?
To do it properly, I suggest you use command line like this:
Step 1: create backup file on old server
mysqldump -u [[user_name]] -p[[password]] [[db_name]] > db_backup.sql
Step 2: Transfer backup file to new server.
Step 3: Import backup file in new server.
mysql -u [[user_name]] -p[[password]] [[db_name]] < db_backup.sql
Pro tip:
you can combine step 1 & 2 if you have remote MySQL enabled on old server. Just execute this command on new server so it will download the backup file in current directory of new server.
mysqldump -h [[xxx.xx.xxx.xxx]] -u [[user_name]] -p[[password]] [[db_name]] > db_backup.sql
where [[xxx.xx.xxx.xxx]] represents ip address/hostname for old server.
Extra Note:
Please note that there is no space between -p and [[password]]. you can also omit the [[password]] if you think it's security issue to include password in command.
If you have access to your terminal you can try using "mysqldump" and also you could try percona xtrabackup tool.
Mysql dump : (If your DB is too large then I suggest you to use screens)
Backup all DB : mysqldump -u root -pxxxx --all-databases > all_db_backup.sql
Backup Tables : mysqldump -u root -pxxxx DatabaseName table1 table2 > tables.sql
Backup Individual databases : mysqldump -u root -pxxx --databases DB1 DB2 > Only_DB.sql
To import : Sync all the files to another server and try importing as show below
mysql -u root -pxxxx < all_db_backup.sql (Use Screen for large Databases)
Individual DB : mysql -u root -pxxx DBName < DB.sql
( Note : Before you import make sure your backuped file already has create database if not exists statements or you could create those DB names before importing )

MySQL 5.6 / Data export doesn't work (dumping data)

What I've been trying to do is to send some data from MySQL to other computers.
I searched the internet for a solution and the best way is probably to put the data into a file, by using the export function.
Soon I encountered an error. Here is part of the log.
Running: "C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin\mysqldump.exe"
--defaults-file="c:\users\takaha\appdata\local\temp\tmpx2hr0e.cnf"
--enable-cleartext-plugin --user=root --host=localhost --protocol=tcp
--port=3306 --default-character-set=utf8 --events --skip-triggers "db_student_comments"
mysqldump: unknown option '--enable-cleartext-plugin'
Operation failed with exitcode 2
14:44:03 Export of C:\Users\takaha\Documents\dumps\Dump20150212.sql has finished with 1 errors
Apparently, this error is similar to this error, but trying the first and second advice on this page didn't solve it, and I've spent more than two days in this problem so far.
I'll put a image of my cmd, since using cmd was recommended at other Stackoverflow pages. This image shows the dumping seems to have successfully been done, but I don't know where the file is. (The "dump" folder was automatically created in C:\Users\username\Documents, but this folder is empty.)
I'd appreciate any advice.
EDIT
Thanks to Danyal, this was solved.
All I had to do was to exactly indicate the directory to create the file after ">".
why don't you use this command?
mysqldump -u'username' -p'password' database_name > back_up.sql
You need to have mysql in the environment variable. If it isn't there, you can go to mysql's bin directory and can execute this command.
Per the docs:
The mysql, mysqladmin, and mysqlslap client programs support an --enable-cleartext-plugin option that enables the plugin on a per-invocation basis.
It does not appear to be a valid option for mysqldump. You shouldn't need it at all unless you're using non-standard MySQL authentication.

Uploading Big MySql Files in Phpmyadmin

Im trying to upload a 3.8gb sql dump into phpmyadmin, in wamp. I set the max_file sizes among other things to 5gb and even restarted the server multiple times. The php_info(); also gives me 5gb as the file size.
I would like to break the file into smaller chunks so that I can upload it bit by bit,if the entire thing isnt possible, and have looked for such tools. Used one though http://www.rusiczki.net/2007/01/24/sql-dump-file-splitter/ but it gives me an error at 2gb.
Could anyone suggest anything that i could do to get my dump into mysql?
Thanks a lot
Traverse to your mysql bin directory (e.g. below)
D:\wamp\bin\mysql\mysql15.1.36\bin>
Then you can import any large database from your dump file giving the following command (e.g. below)
mysql -u username -ppassword database_name < dump.sql
You should really skip phpmyadmin and do it through the command line. The correct command is:
$ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
If you are still unsure about that one (although try it, you'll be surprised how easy it is) you can have a go at mysql workbench.

Issue with duplicating a MySQL database

I'm trying to "clone" a MySQL database. The problem is with views. When I export a view, the .sql defines the view as database_name.view_name. It doesn't do this for tables, just views. This obviously creates a problem when importing to the second database - the view doesn't get created.
I think I've found the answer. The problems I was running into were being created by phpMyAdmin. From the command line (make sure to create the target database first):
mysqldump -u [username] -p[password] [old_database_name] > dump.sql
mysql -u [username] -p[password] [new_database_name] < dump.sql
No problems.
One thing you may want to try is SqlYog Community, I use it all the time for MySQL and it seems to do a great job of copying entire databases from one server to another, or even on the same server.

mysql import on windows

I have a MySQL file, db.sql. I have tried to import it using:
mysql -uroot -p[password] db < db.sql
All I get is a listing of mysql commands, or I get a syntax error. The weird thing is I used this file last week and, as far as I know, I'm doing it the same way.
I create the database, then in command line enter the above but it's not working. I've tried being inside mysql and just at command line and nothing seems to be working.
Is there something I should be doing differently in windows or MySQL5? I don't know how the heck I got it to work the first time...
TIA
Try this instead:
mysql -u root -p
(prompts for password)
use db;
source db.sql
I found out it is different to run this command from Windows Command Line (cmd.exe) and Windows PowerShell.
Using CMD.exe the command works okay, but in PowerShell I get this error:
mysql -uroot exampledb < exampledb.sql
The '<' operator is reserved for future use.
Not sure if your example was a typo or not, but for starters you need to have a space in between your flags and their values, roughly like this:
mysql -u root -p [password] db < db.sql
If you are already logged in the try this it will be very useful, but depend upon the MySQL version, it works on MySQL 5.0
For log in if you are not already logged in.
mysql>[your password]
Other wise, use the database to which you want to import the SQLDump file by command.
mysql>use [your database name]
And then give source the database Dump file path as blow command(If not works the copy Dump database file to the bin folder where the MySQL installed for eg. "C:/programfiles/mysql/mqlserver5.0/bin")
mysql> source [dataBasePath+name.sql or dataBaseName.sql]
I've been using PHP script called "BigDump":
http://www.ozerov.de/bigdump.php
This perfectly works
mysql>[your password]
Other wise, use the database to which you want to import the SQLDump file by command.
mysql>use [your database name]
And then give source the database Dump file path as blow command(If not works the copy Dump database file to the bin folder where the MySQL installed for eg. "C:/programfiles/mysql/mqlserver5.0/bin")
mysql> source [dataBasePath+name.sql or dataBaseName.sql]EG: source C:.....sql
I am using mysql server 5.5
In Windows PowerShell, you can pipe in the contents like so:
Get-Content db.sql | mysql -u root -p [password]