Moving connections and instances between two computers - mysql

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!

Related

How to change MySQL data directory to workspace folder for syncing databace between devices?

My problem is that I want to have my MySQL database in my workspace folder. I want to sync my database for all of my workdevices, so that i dont have to export my data every single time a change something.
I tried to create just a softlink to the direktory on every device I use with the mklink /D command in the commandline but I see that this doesn'n work.
Have you any idea how i can configure my database right this?
Here is the solution on stackexchange site : change data dir path
Just follow the step by step solution by RolandoMySQLDBA

windows could not start the MySQL. service on local computer. Error 2 : The system cannot find the file specified

I am not able to start the MySQL server on my Windows system. When I tried in services.msc to run, I got this error:
Starting it through the XAMPP control panel does not work either:
Can you help me to solve this?
Open windows services (Start->run ->Services.MSC)
Find service with name "Mysql Server" and check path, it should be something like that:
"C:\Program Files (x86)\Parallels\Plesk\Databases\MySQL51\bin\mysqld.exe" "--defaults-file=C:\Program Files (x86)\Parallels\Plesk\Databases\MySQL\Data\my.ini" MySQL
Make sure that Mysql folder and executable file mentioned above exist by this path.
OR
Sometimes the file name of mysqld-nt.exe renamed to mysqld-nt.exe~ so rename it back to its original name and this may solve the problem.
Go to the path: C:Programs Files\MariaDB 10.2\data..
Lookout for my.ini file. Open the file and check the path for "datadir".
If that does not match to your installed directory then update it.
Your problem will be solved for sure.
I faced the same problem and solved it.
Just modify the registry editor value.
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/MySQL/ImagePath

XAMPP Linux: make mysql accessible by just typing "mysql"

I have a strange issue. On my PC with Linux Mint 17 I can access mysql just by typing mysql in the terminal, but on my laptop (with Ubuntu 15.04) I have to type each time /opt/lampp/bin/mysql (both have the latest XAMPP version installed).
So my question is: how to make mysql "global" and accessible by just typing "mysql"?
You need to add /opt/lampp/bin/ to your $PATH so that the system can find the binary file.
From the command line enter:
PATH=$PATH:/opt/lampp/bin
+1 for doublesharp's answer. Otherwise, you could do:
alias mysql=/opt/lampp/bin/mysql
This avoids making everything in /opt/lampp/bin/ immediately accessible on the path, which may or may not be desired.
As said by #doublesharp, enter this line into the file .bashrc in your home directory
export PATH=$PATH:/opt/lampp/bin

Uploading small .sql file to MySQL database file returns error (XAMPP on OS X)

I am running a fresh install of XAMPP 1.8.2 for OSX and am currently trying to upload an exported database that is 171kb in size.
Getting hit with this error
Warning: File upload error - unable to create a temporary file in Unknown on line 0
From what I have discovered it may have something to do with write permissions to a /tmp file which doesn't seem to exist on my system.
Trying to set this up so I can make changes locally on a clients website without breaking the live site.
Cheers and thanks for taking a look.
Solved
within the file uploads section of your php.ini there resides this:
;upload_tmp_dir =
To allow for uploads uncomment and give the tmp dir a home:
upload_tmp_dir = "/tmp"
The the most recent default installation of XAMPP on Lion has a couple of very important lines commented out (in regards to phpmyadmin/mysql). Not sure why, but I would love to learn the reasoning behind it.

How to use GVIM to edit a remote file?

I use GVIM on Ubuntu 9.10. I'm looking for the right way to configure GVIM to be able to edit remote files (HTML, PHP, CSS) by for exemple ftp.
When i use :e scp://username#remotehost/./path/to/file i get: error detected while processing BufEnter Auto commands for "*":E472: Command failed.
When i open a file on remote via Dolphin or Nautilus, i cannot use other files with NERDTree.
Finally when i edit on remote a file via Dolphin the rights are changing to access interdit.
So how to use GVIM to edit remote files like on my localhost?
I've found running the filesystem over ssh (by means of sshfs) a better option than having the editor handle that stuff or running the editor itself over an ssh tunnel.
So you need to
apt-get install sshfs
and then
sshfs remoteuser#remotehost:/remote/path /local/mountpoint
And that will let you edit your remote files as if they were on your local file system.
To make it even smoother you can add a line to /etc/fstab
sshfs#remoteusername#remotehost:/remote/path /local/mountpoint fuse user,noauto
For some reason I find that I have to use fusermount -u /local/mountpoint rather then just umount /local/mountpoint when experimenting with this. Maybe that's just my distro.
Recently I've also noted that the mounting user must be in the fuse group. So:
sudo addgroup <username> fuse
An other popular option of course, would be to run vim (rather then gvim) inside a GNU Screen session on one machine and connect to that session via ssh from wherever you happen to be. Code along all day at work and in the evening you ssh into your office computer, reattach to your gnu screen session and pick up exactly where you left off. I used find the richer color palette to be the only thing I really missed from gvim when using vim, but that can actually be fixed thanks to a fork of urxvt that will let you customize the entire 256 position color palette, not just the 16 first positions of the palette that most terminal emulators will let you customize.
There is one way and that is using the remote host's copy, using SSH to forward the X11 client to you, like so:
user#local:~/$ ssh -X user#host
...
user#host:~/$ gvim file
The latter command should open gvim on your desktop. Of course, this relies on the remote host having X11 / gnome / gvim installed in the first place, which might not be the solution you're looking for / an option in your case.
Note: X11 forwarding can be a security risk.
In order for netrw to work seamlessly, I believe you need to not be in compatibility mode.
Try
:set nocompatible
then
:edit scp://host/path/to/file
Try this
:e scp://username#remotehost//path/to/file
Note that the use of // is intentional after remotehost it gives the absolute path of your file
:)
http://www.celsius1414.com/2009/08/19/how-to-edit-remote-files-with-local-vim/
The vim tips wiki has an article on this, Editing remote files via scp in vim.
EDIT: Key authentication is not necessary for opening files over ssh. Vim will prompt for password.
It would be useful to note if netrw.vim was loaded by vim when it started.
:echo exists("g:loaded_netrwPlugin")
For opening files over ssh, you need your local machine's public key in the server's authorized keys. Following help section in vim documentation explains it pretty well.
:help netrw-ssh-hack
Quick way to export public key would be by using ssh-copy-id (if available).
ssh-copy-id user#host
And have a look at netrw documentation for network file editing over other protocols.
:help netrw
HTH.
According to the docs BufEnter is processed after the file has been read and the buffer created, so my guess is that netrw successfully read the file but you have a plugin that assumes the file is on the local filesystem and is trying to access it, e.g. to run ctags.
Try disabling all your plugin scripts except the default Vim ones, and then editing the file.
Also, try editing a directory to see if netrw can read that - you need to put the / on the end so that netrw knows it is a dir.
About your command, :e scp://username#remotehost/./path/to/file : note that with netrw, scp is taken relative to your home directory on that remote host. To avoid home-relative pathing, drop that "."; ie. :e scp://username#remotehost//path/to/file .
to accomplish this on windows download/install the Dokan library and Dokan SSHFS, which are the first and last links on this page.
I didn't think you were going to be able to directly edit a remote file using GVIM running locally. However, as others have pointed out, this is defintiely possible. This looks very interesting; I will check this out. I will leave the rest of my post up here, in case it is useful to anyone else, as an alternative method. This method will work even if you don't have SSH access to the file (ie, you only have FTP, or S3, or whatever).
You may get that effect, though, by tying GVIM into a graphical file transfer application. For example, on OS X, I use CyberDuck to transfer files (FTP, SFTP, etc). Then, I have it configured to use GVIM as my editor, so I can just double-click on a file in the remote listing, and CyberDuck will download a copy of that remote file, and open it in GVIM. When I save it in GVIM, CyberDuck uploads the file back to the remote host.
I'm sure that this functionality is not unique to CyberDuck, and is probably present in most nicer file transfer utilities.