I hope you can help me - I used to use AMPPS, but unfortunately due to the Big Sur update it no longer works. so downloaded xampp vm stack. Now can't get a database I need.
I have gone into the Ampps folder and copied out the relevant physical database but copying this into the xampp folder it won't let me. I have attempted to change the permission via chmod -R 777 /Users/samjacksom/.bitnami/stackman/machines/xampp/volumes/root/var/mysql and via get info both won't allow me to do so.
Would anyone please have a solution to have I can get my database from the old Ampps?
UPDATE:
I have got a Catalina Virtual Machine running with Ampps. And, transferred the files onto there. For the database I copied the db folder from the var folder on ampps on my host to the vm location.
However, when I go into phpmyadmin the database is not unfortunately visible. Could someone advise how I can physically migrate a database?
why don't you just use mysqldump?
$ mysqldump -u [user] -p [database_name] > [filename].sql
or to get a backup of the entire database:
$ mysqldump --all-databases --single-transaction --quick --lock-tables=false > full-backup-$(date +%F).sql -u root -p
then you can restore your backup on new stack just by running:
$ mysql -u [user] -p [database_name] < [filename].sql
Related
I am working on a Rails application in Lubuntu. It has MySQL database at the back end. I want to move the application with the Database to my new Ubuntu OS. I can move the Rails project by using Git, but I am not sure how to move the MySQL database. I was wondering if there is a quick way to move the database. I would appreciate any help.
Thanks
You can move the data by taking a mysqldump.
mysqldump -u [user_name] -p -h [hostname] [database_name] > [file_name.sql]
Use this in the terminal with the relevant attributes, upon success it will generate a MySQL dump file which you can later to use to restore your database to another machine. Also since the structure of the database is remaining the same, applying migrations from rails will show no changes, then you are good to work with it in the new machine.
Follow these steps:
1) For exporting the db dump into the local system
mysqldump -u [username] -p [db_name] > [sql_file_name.sql]
2) Make its tar for easily share with other system:
tar -czvf [any_name.tar.gz] [sql_file_name.sql]
3) Move it to the other system where you have to import it.
4) Untar the file:
tar -xzf [any_name.tar.gz]
5) Import database:
mysql -u [username] -p [db_name] < [sql_file_name.sql]
I recently tried to put my web application and mysql database on the same virtual server. Now I receive a port error. In order to fix the port issue, I want to back up the database and reinstall WAMP. Since I can't get to the phymyadmin, I have to use the mysql command prompt to do a dump.
Would anyone happen to know the EXACT command to put in, if my username is root, I have no password, and the database name is dev? I've tried it multiple ways and I get an error saying that my syntax is wrong.
Thanks in advance.
You can use the following command provided you know the name of the database:
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
Alternatively I would install the MySQL Workbench which can connect to your local database instance and provides a GUI to run the export: MySQL Workbench.
Unfortunately if you've uninstalled WAMP then MySQL might not be running anymore, and the above commands will not work because the utilities cannot see the database. If this is the case, try installing WAMP to a new directory and manually copying over the MySQL data files:
How to restore MySQL database from WAMP?
mysqldump -u root -p dev > devBackUp.sql
DOS batch file to export the database with date and time in the filename
FOR /f "tokens=1-8 delims=:./ " %%G IN ("%date%_%time%") DO (
SET dt=%%G%%H%%I_%%J_%%K
)
mysqldump -u root -p[root_password] [database_name]> [database_name]_%dt%.sql
pause
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
How do I export/import large database on MAMP ? Using PHPMyAdmin does not work as it supposed to be.
It should be done via terminal as below.
In the terminal navigate to bin folder of MAMP using below command cd /Applications/MAMP/library/bin
Use this command to export the file ./mysqldump -u [USERNAME] -p [DATA_BASENAME] > [PATH_TO_FILE]. EG would be ./mysqldump -u root -p my_database_name > /Applications/MAMP/htdocs/folder_name/exported_db.sql
Line should appear saying Enter password:. Here enter the MySQL password. keep in mind that the letters will not appear, but they are there.
If you need to import use BigDump Which is a MySQL Dump Importer.
Turn on MAMP!
Then, for both operations, open the terminal and type:
EXPORTING:
/Applications/MAMP/library/bin/mysqldump -u [USERNAME] -p [DATABASE_NAME] > [PATH_TO_SQL_FILE]
Then type your password in prompter (default root) and press enter.
Example:
/Applications/MAMP/library/bin/mysqldump -u root -p my_database_name > /Applications/MAMP/htdocs/folder_name/exported_db.sql
IMPORTING (will erase current database):
/Applications/MAMP/library/bin/mysql -u [USERNAME] -p [DATABASE_NAME] < [PATH_TO_SQL_FILE]
Then type your password in prompter (default root) and press enter.
Example:
/Applications/MAMP/library/bin/mysql -u root -p my_database_name < /Applications/MAMP/htdocs/folder_name/exported_db.sql
/!\ Important Warning: Make sure to backup your current database before doing this command in case you need a copy of it before importing. This will erase your current database!
You can also use the Sequel Pro App if you are using MAMP PRO version to get around the defaults that phpMyAdmin gives you.
I had a problem to dump my db from MAMP. Tried a lot of things, but always this error:
Got error: 2002: Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock'
Tried to create a symlink, but it was already created "ln: /tmp/mysql.sock: File exists"
Thought the problem was new Mac or new MAMP.
Finally in my case (problem was in me) solution was really simple: just turn on MAMP :)
Maybe it will help someone to save a little bit time (I spent around 4 hours)
I'm creating a snippet to be used in my Mac OS X terminal (bash) which will allow me to do the following in one step:
Log in to my server via ssh
Create a mysqldump backup of my Wordpress database
Download the backup file to my local harddrive
Replace my local Mamp Pro mysql database
The idea is to create a local version of my current online site to do development on. So far I have this:
ssh server 'mysqldump -u root -p'mypassword' --single-transaction wordpress_database > wordpress_database.sql' && scp me#myserver.com:~/wordpress_database.sql /Users/me/Downloads/wordpress_database.sql && /Applications/MAMP/Library/bin/mysql -u root -p'mylocalpassword' wordpress_database < /Users/me/Downloads/wordpress_database.sql
Obviously I'm a little new to this, and I think I've got a lot of unnecessary redundancy in there. However, it does work. Oh, and the ssh command ssh server is working because I've created an alias in a local .ssh file to do that bit.
Here's what I'd like help with:
Can this be shortened? Made simpler?
Am I doing this in a good way? Is there a better way?
How could I add gzip compression to this?
I appreciate any guidance on this. Thank you.
You can dump it out of your server and into your local database in one step (with a hint of gzip for compression):
ssh server "mysqldump -u root -p'mypassword' --single-transaction wordpress_database | gzip -c" | gunzip -c | /Applications/MAMP/Library/bin/mysql -u root -p'mylocalpassword' wordpress_database
The double-quotes are key here, since you want gzip to be executed on the server and gunzip to be executed locally.
I also store my mysql passwords in ~/.my.cnf (and chmod 600 that file) so that I don't have to supply them on the command line (where they would be visible to other users on the system):
[mysql]
password=whatever
[mysqldump]
password=whatever
That's the way I would do it too.
To answer your question #3:
Q: How could I add gzip compression to this?
A: You can run gzip wordpress_database.sql right after the mysqldump command and then scp the gzipped file instead (wordpress_database.sql.gz)
There is a python script that would download the sql dump file to local. You can take a look into the script and modify a bit to perform your requirements:
download-remote-mysql-dump-local-using-python-script