How to sync Mamp's mysql data folder to Dropbox - mysql

I use Mamp and recently (yesterday) I lost, apart from a two weeks old backup, all of my databases due to a unwanted disk wipeout. !kcuf
Coding is more or less intact as I moved the apache code under a dropbox folder.
So my question is, just in case it happens again, how can I sync Mamp's databases to Dropbox?

Source : Syncing MAMP with Dropbox
Open terminal and type the following commands:
A: cd ~/Dropbox/localfolder (opens the directory to put the database in)
B: cp -r /Applications/MAMP/db dbfolder (copies it into a new folder within)
C: rm -rf /Applications/MAMP/db (remove the database from MAMP folder)
D: ln -s ~/Dropbox/localfolder/dbfolder /Applications/MAMP/db (creates a direct link for MAMP without getting hands deep in coding)
Start up MAMP (If already started, just restart as it will then get the new MySQL route)
Feel much more secure
If it is already synced but somehow your Mac went all Windows on you*, Reinstalling Mamp and Dropbox and doing steps C and D will do the job.
By the way, in order to make Dropbox the location of your Mamp locals, move your all of your files to the folder of your choice and, starting Mamp, go to preferences, Web server, and Document root to change it to the new one.
Saves on recoding big deal.
*Not intended seriously here

Related

duplicate mediawiki between 2 locations

I have setup a private wiki (1.35.1) running on Ubuntu Mate which is a guest OS on VMWare Workstation 16. I'd like to run this wiki at 2 locations (A & B) that are isolated (no VPN connection). I will be the only user accessing since it is my private wiki.
I've got the wiki setup and running at location A and will simply archive the guest and bring it up at location B as an identical copy.
Question: After I spend the day at location A (editing my wiki there), can i just simply copy the entire /var/www/html/Mediawiki folder and the entire /var/lib/mysql folder (MariaDB) onto a thumb drive and dump onto location B?
The intent is for these to be identical wiki's - synchronized by me (sneakernet) with thumb drive.
UPDATE - this is working well so far. Below is how i do it.
Stop the mysql server - sudo service mysql stop
Copy (using rsync) all new or changed files from /var/lib/mysql/ to my external share with:
sudo rsync -cavurt --delete --info=del,name,stats2 "/var/lib/mysql/" "/home/rp/shares/VM_share_ubuntu/wiki_sql_files"
Copy all new or changed files from /var/www/html/mediawiki-1.35.1 to my external share with:
sudo rsync -cavurt --delete --info=del,name,stats2 "/var/www/html/mediawiki-1.35.1/" "/home/rp/shares/VM_share_ubuntu/wiki_mediawiki_files"
Start the mysql server - sudo service mysql start
Now, copy the new/changed files to the 2nd machine:
Stop the mysql server - sudo service mysql stop
Copy in (using rsync) all new or changed mysql files with:
sudo rsync -cavurt --delete --info=del,name,stats2 "/home/rp/shares/VM_share_ubuntu/wiki_sql_files/" "/var/lib/mysql"
Copy in all new or changed mediawiki files with:
sudo rsync -cavurt --delete --info=del,name,stats2 "/home/rp/shares/VM_share_ubuntu/wiki_mediawiki_files/" "/var/www/html/mediawiki-1.35.1"
Start the mysql server - sudo service mysql start
In those rsync commands note that the end of the source folder needs to be / and the target folder does NOT have the ending /. The significance of that is explained in this thread.
UPDATE 2: If you modify the /etc/php/7.4/apache2/php.ini file on one machine you will need to make sure to make the same update on the other machine. e.g. If you change the file upload size from the default 2M or some other change that affects php.ini.
This would mostly work as long as you set $wgServer dynamically. Pages that use absolute URLs and are loaded from cache would link to the wrong URL, but that should be very rare - almost everything uses relative URLs.

XAMPP MAC OSx - use external USB drive for MySQL storage

I'm using fairly large MySQL DB Tables with XAMPP, which makes it tough with my rather small internal storage of my Mac. I thought I would just keep MySQL data on an external USB3.0 SSD drive, but it looks like it's not that easy.
Here is what I've tried:
With XAMPP ( not VM ): Moved /Applications/XAMPP/xamppfiles/var/mysql to /Volumes/myexternalssd/mysql and then pointed everything in my.cnf to that dir. The permissions seem to have copied properly. But it didn't work. MySQL does not start at all if I trash the original dir, or just keeps using the original dir if I leave it in place.
With XAMPP-VM: Moving ~/.bitnami dir to the ext drive and then symlinling ( ln -s ) to the new location. The error is then:
Cannot load stack definitions.
Dtails:
1 error occurred:
* failed to create stack: cannot deserialize stack from file "/Users/arseni/.bitnami/stackman/machines/xampp/metadata.json": open /Users/arseni/.bitnami/stackman/machines/xampp/metadata.json: operation not permitted

Is it OK to move an old MySQL data folder to a new MySQL install's folder?

I've installed MySQL on my Mac running lion using their DMG installer. This has created 2 folders, mysql-5.5.15-osx10.6-x86_64 and mysql-5.5.9-osx10.6-x86_64 with a symlink from /usr/local/mysql/ leading to the newer one. My databases are still in the old folder, in the data folder.
Is it OK to just delete the new data folder, then move the old data folder into the newly installed folder (/usr/local/mysql-5.5.15-osx10.6-x86_64) using this:
sudo mv /usr/local/mysql-5.5.9-osx10.6-x86_64/data /usr/local/mysql-5.5.15-osx10.6-x86_64/data
Are there any gotchas I need to worry about? Is it smarter to just change this in the configuration file?
You should look at your my.cnf file to see which folder it is pointing to as the datadir. If you delete the folder it's pointing to, it won't know where to find your data. You can change this value to point to where ever you want your data stored.

MySQL tables on external hard drive

I have a large amount of text data I need to import into MySQL. I'm doing this on a MacBook and don't have enough space for it so I want to store it in an external hard drive (I'm not really concerned about speed at this point - this is just for testing).
What's the best way to do it?
Install MySQL on the external hard drive (is this possible on a Mac?)
Install MySQL on the laptop's hard drive and have the tables on the external (how?)
One simple hack is to create an symbolic link replacing your current mysql database file location pointing to the external disk. Google symbolic link.
sample usage would be after you shutdown mysql, change the old mysql db folder name to something else, and create the symbolic link using the ln command like below
ln -s [EXTERNAL DRIVE PATH] [MYSQL DB FOLDER PATH]
Then move all the previous content of the mysql db folder to the new location.
Open /etc/mysql/my.cnf and find the value of the datadir. Alternatively, you can find this out in the mysql monitor with
mysql> select ##datadir;
Stop mysql
sudo systemctl stop mysql
Copy the data from there to your external drive
sudo rsync -av /var/lib/mysql /mnt/myHDD/somedir/mysql
Modify the location of the datadir in my.cnf.
Start mysql again
sudo systemctl start mysql
Verify that everything is still fine and remove the original data dir.
This page contains a more extensive guide but all the additional issues it warns about were not relevant for me on my raspberry PI. I.e. I skipped them and it worked.
For the second option, a tablespace might do the trick:
http://dev.mysql.com/doc/refman/5.1/en/create-tablespace.html
User user658991 answer is halfway there.
After adding the soft link, you will need to add the following line to /etc/apparmor.d/usr.sbin.mysqld beneath the 2 lines to the old mysql folder.
/path/to/mysql/folder/on/the/external/ r
/path/to/mysql/folder/on/the/external/ ** rwk
Without these 2 lines, MySQL fails to start complaining of:
Can't create test file /path/to/mysql/folder/on/the/external/hostname.lower-test
Can't create test file /path/to/mysql/folder/on/the/external/hostname.lower-test
mysqld: Can't change dir to '/path/to/mysql/folder/on/the/external/' (Errcode: 13)
Restart apparmor for the changes to take effect.
sudo invoke-rc.d apparmor restart
With this, MySQL starts normally.

Moving connections and instances between two computers

I´ve got a mysql-server that I´m administrate remotely with MySQL Workbench.
Now I´ve got a new computer and I cant find any solution to move my connections and instances-profiles to my new computer. This can´t be an unsolved question, huh? Not the first time this would happen for someone else.
Correction: It´s not the server-instances that I want to move. I need to export/move/backup my many client-profiles/instances-connections in MySQL Workbench.
You don't need to copy any files manually as other answers suggest. On both Windows and Mac you can export all your settings within MySQL Workbench and restore to another system.
Select Tools > Configuration > Backup Connections
This will export as a .zip. Then on your new new install just
Select Tools > Configuration > Restore Connections
That's it!
I had the same questions. I found a MySQL directory in %APPDATA%. Copy the entire directory to the same location on the new machine. You'll need clear your passwords and re-enter them. Once I did that, I was up and running again.
You can find your %APPDATA% folder in Windows by entering it in the address bar of Windows Explorer.
Found it on a mac in
/Users/Username/Library/Application Support/MySQL/Workbench/
file called connections.xml
Backup and restore connections using the menus Tools > Configuration > Backup Connections and Tools > Configuration > Restore Connections is the easiest way, however it does not copy the passwords.
Extracting the passwords is possible in the following case:
Old PC should be a Windows installation.
You should be able to login using the Windows account who originally saved the passwords in Workbench, i.e. without having the Windows account's password reset by an admin.
If the above requirements are met, one can log into the old PC and run the decrypt tool found on http://www.donationcoder.com/forum/index.php?topic=41860.msg391762#msg391762
The C++ code to decrypt is shown below (credits: f0dder)
std::vector<unsigned char> decrypt(BYTE *input, size_t length) {
DATA_BLOB inblob { length, input };
DATA_BLOB outblob;
if (!CryptUnprotectData(&inblob, NULL, NULL, NULL, NULL, CRYPTPROTECT_UI_FORBIDDEN, &outblob)) {
throw std::runtime_error("Couldn't decrypt");
}
std::vector<unsigned char> output(length);
memcpy(&output[0], outblob.pbData, outblob.cbData);
return output;
}
In Linux (Ubuntu), the location was changed to $HOME/.mysql/workbench
Tested on Ubuntu 14.04 LTS.
Before replacing the connection.xml, make sure you close the Workbench application first, or the application will overwrite/save on the xml file on exit.
just copy them!
in Linux, they're at $HOME/.mysqlgui/
If you want to recover the passwords that are encrypted in "workbench_user_data.dat" file using Python in Windows, you can use the below snippet.
import os,win32crypt
encrypted_data = open(f"C:\\Users\\{os.getlogin()}\\AppData\\Roaming\\MySQL\\Workbench\\workbench_user_data.dat", "rb").read()
clear_data = win32crypt.CryptUnprotectData(encrypted_data, None, None, None, 0)
print(clear_data)
Sadly, on the latest version of the MySQL Workbench (8.0.25, 8.0.27 in windows at least), the backup and restore for .zip file formats does NOT work.
See here for details and a workaround:
https://bugs.mysql.com/bug.php?id=102501
I found the file "WbProfiles.xml" in path C:\Users\.sqlworkbench\WbProfiles.xml
Either copy the file or copy complete ".sqlworkbench" folder under same path in new machine.
BACKUP work-around for this bug:
copy these two files: connections.xml and server_instances.xml
location of these files (in windows) is: C:\Users<user>\AppData\Roaming\MySQL\Workbench (replace with your own windows username)
To RESTORE:
copy those above 2 files to the same location on the destination installation.
caveat: I don't know where the password "vault" is kept for the connections, so you may have to re-enter those, but the connections and server list are preserved.
Bonus: to restore your workspaces (all open .sql tabs, etc.) you can also copy the "sql_workspaces" directory underneath the "workbench" directory and it will restore those too!