Set up MySQL Database dump onto local computer - mysql

I have a file called database.dmp that is the mysql dump from the server last night. User is probably root.
I want to create a local copy on my computer 'MARK-PC' (I definitely do not overwrite the live database on the server).
What is the best command to do this?
1a. Can I use that command from the microsoft windows command prompt? I am not that familiar with the mysqldump command line and don't want to screw anything up.
Will I need to have root access?
If I set it up with another user/password, what issues will I run into if any?

Related

How to migrate 10GB old table to new table? [duplicate]

I am using phpmyadmin on my windows os. I have a database with one table which has 100M records with the size of 20GB. I want to export this table and have the table.sql file. Whenever I try to do this, the size of the exported file is 0 bytes. When I check the apache error log, the following would show up:
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 1066139648 bytes)
Any idea how to solve this problem?!
Thanks :)
I would suggest to try using the command line and the mysqldump.exe utility, as suggested here
If you have shared hosting and you are using Cpanel then they are providing you the option to backup your database in the following section.
Files => Backup => Download a MySQL Database Backup.
If you are on a shared hosting or you don't have access to shell, then use mysqldumper script; copy it to your server and start it in your browser under "yourDomain.com/path_to_mysqlumper/"
MySQLDumper is a PHP and Perl based tool for backing up MySQL
databases. You can easily dump your data into a backup file and - if
needed - restore it. It is especially suited for shared hosting
webspaces, where you don't have shell access.
If you have shell access to your host servers (if provided by your host since not all shared server hosters give this access) then you may use SSH access like in this tutorial using Putty that you install and configure then import or export your databases like in this third tutorial.
I try mysqldump for many hours but didnt work, until I started a superuser console.
First, start a superuser console
sudo su
Then, try the complete command
/opt/lampp/bin/mysqldump -u root -p [DATABASE NAME] > [PATH_FOR_BACKUPFILE]/[FILE_NAME].sql
I my case, it was something like /opt/lampp/bin/mysqldump -u root -p database > /home/user/backup.sql
MySQLDumper worked like a charm for me at my hosted website. I had to copy one database and "paste" it into a new database. In MySQLDumper, it isn't apparent right away how to do this, but the key is to create a new configuration file in MySQLDumper and that will allow you to copy/restore to different databases.
On the home screen in MySQLDumper, click Configuration, then Configuration Files. There is a text box at the top allowing you to create a new Configuration file. In there, put in the information for the second database you need (you created a connection to the first database when you install MySQLDumper). Save it. Then you can click Restore where you can select the dump of the first database and restore it in the second one.
This was a lifesaver. Thanks!
increase
max_post_size
variable in php.ini file. Then you will be able to download it.
I had a different issue when I was downloading from phpmyadmin in the middle like 180MB download stops with message - network error
So I used ssh connection which you can find in your cpanel sometimes they provide browser based terminal or sometime you have to access it using putty .
In terminal I go inside my public_html folder where all my files are stored . Followed by this command:
mysqldump -u [username] -p [database-you-want-to-dump] > [path-to-place-data-dump.sql]
This did the job in few minutes and saved a sql file in my public_html folder. Then I opened the folder in File manager and downloaded it from there.
You can also use FTP or you can download it directory by accessing by url.
Make sure you delete it after your download finishes.

Automate Putty To Do Daily Task

I am fairly new to putty, need your help guys I would repeatedly connect to a linux server using putty almost everyday then connect to one more linux sever from within previous linux server as it contains database, then login to mysql and take a database back up
I want to automate this process by creating a bat file as am on windows 7, i was able to login to putty and then to mysql, but console disappears after that
login to putty with username password
ssh to another server and login with username password
login to mysql then take a db back up using mysql dump
copy the db backup file to desktop
Thanks in advance
When your goal is making the backup, you do not need to automate Putty. You can make a unix script that will call mysql and make a backup. When that script works, you can add it to crontab (Unix scheduler), so it will run every day.
You need some more testing before crontab works well: your environment in an interactiv session will be different.
Edit: Did not answer the last part:
And 4. copy the db backup file to desktop
There are different ways for transporting the backup. You can have a mounted drive, shared directory, or use some transport protocol like rsync or scp. I can not tell which fits best in your situation.

MySQL Not loading Database File from /usr/local/mysql/data

Hey Guys so the other day I was running a database schema in the mysql workbench on my mac. I had added tables populated the data and tried to run some big queries. The server died and now when I connect to my local host instance I cannot find my database. However I can still see my database file in /usr/local/mysql/data/
Can any one help me work out how to start mysql server again and get it to load in the file?
I just dont' understand why it can no longer see the schema..
Connecting as localhost, using root, both workbench and terminal can't see the file. However the file is here:
The file I want is AM_DUMPS
When I try and load it from SQL Workbench I get:
Check to see if the data directory is owned by MySQL or mysqld is not launched as the mysql user. It looks like something along those lines. You may have to adjust the permissions to make sure that mysql is the owner.

Can a MySQL database be recovered from just the data directory (and no SQL backups)?

My PC crashed and I lost my WAMP files. Although I have a copy, I do not know how to retrieve the database. Can I copy the WAMP files to another system and then access phpMyAdmin or something? I think it's not possible.
Any other ways where I could do so? I have tried re-installing. But I have no idea how to retrieve them. All I have is just a copy of the WAMP server folder.
You can make dump for necessary databases
Open CMD and type
[Replace brackets and information inside with your parameters]
\wamp\bin\mysql\{mysql5.5.24}\bin\mysqldump.exe -u {root} -p{} {dbname} > \Users\{username}\Desktop\dump.sql
The opposite action its:
\wamp\bin\mysql\{mysql5.5.24}\bin\mysql.exe -u {root} -p{} {dbname} < \Users\{username}\Desktop\dump.sql

export large database mysql phpmyadmin

I am using phpmyadmin on my windows os. I have a database with one table which has 100M records with the size of 20GB. I want to export this table and have the table.sql file. Whenever I try to do this, the size of the exported file is 0 bytes. When I check the apache error log, the following would show up:
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 1066139648 bytes)
Any idea how to solve this problem?!
Thanks :)
I would suggest to try using the command line and the mysqldump.exe utility, as suggested here
If you have shared hosting and you are using Cpanel then they are providing you the option to backup your database in the following section.
Files => Backup => Download a MySQL Database Backup.
If you are on a shared hosting or you don't have access to shell, then use mysqldumper script; copy it to your server and start it in your browser under "yourDomain.com/path_to_mysqlumper/"
MySQLDumper is a PHP and Perl based tool for backing up MySQL
databases. You can easily dump your data into a backup file and - if
needed - restore it. It is especially suited for shared hosting
webspaces, where you don't have shell access.
If you have shell access to your host servers (if provided by your host since not all shared server hosters give this access) then you may use SSH access like in this tutorial using Putty that you install and configure then import or export your databases like in this third tutorial.
I try mysqldump for many hours but didnt work, until I started a superuser console.
First, start a superuser console
sudo su
Then, try the complete command
/opt/lampp/bin/mysqldump -u root -p [DATABASE NAME] > [PATH_FOR_BACKUPFILE]/[FILE_NAME].sql
I my case, it was something like /opt/lampp/bin/mysqldump -u root -p database > /home/user/backup.sql
MySQLDumper worked like a charm for me at my hosted website. I had to copy one database and "paste" it into a new database. In MySQLDumper, it isn't apparent right away how to do this, but the key is to create a new configuration file in MySQLDumper and that will allow you to copy/restore to different databases.
On the home screen in MySQLDumper, click Configuration, then Configuration Files. There is a text box at the top allowing you to create a new Configuration file. In there, put in the information for the second database you need (you created a connection to the first database when you install MySQLDumper). Save it. Then you can click Restore where you can select the dump of the first database and restore it in the second one.
This was a lifesaver. Thanks!
increase
max_post_size
variable in php.ini file. Then you will be able to download it.
I had a different issue when I was downloading from phpmyadmin in the middle like 180MB download stops with message - network error
So I used ssh connection which you can find in your cpanel sometimes they provide browser based terminal or sometime you have to access it using putty .
In terminal I go inside my public_html folder where all my files are stored . Followed by this command:
mysqldump -u [username] -p [database-you-want-to-dump] > [path-to-place-data-dump.sql]
This did the job in few minutes and saved a sql file in my public_html folder. Then I opened the folder in File manager and downloaded it from there.
You can also use FTP or you can download it directory by accessing by url.
Make sure you delete it after your download finishes.