Combining two installs of mysql - mysql

Noobish questions
The StartupParameters.plist points to MySQL 5.5.27-community. When I run Querious, a database management application, and create a db, it adds the db to an older version - MySQL 5.5.18 (specifically to usr/local/mysql-5.5.18-osx10.5-x86_64/data).
Questions: how do I move the dbs in the older version of MySQL to the current one? If I do, and then delete the old MySQL directory, will I be ok or are there other changes which need to be made?
Thanks,
Cole

You should simply dump the old databases using mysqldump or similar. Then import those dumps into the new server. You should then be able to safely uninstall your old server and remove the directories.

This is a simple case of exporting the databases and then importing them to another. In your case, use mysqldump to export the database from the older server and use mysql import to import into the newer one.
It is okay to safely uninstall the older version once the database has been exported.
usr/local/mysql-5.5.18-osx10.5-x86_64/> mysqldump -u username -p database > exported.sql
(location of the newer db)>mysql -u username -p -h localhost database < exported.sql

Related

Missing MySQL users after migration using Plesk Migration Tool

so I'm not a server expert. Managed to migrate a server using Plesk's migration tool. All Plesk managed DBs were moved. But discovered that all DBs and users managed through MySQL were not migrated. Can anyone tell me a solution to this?
This is an expected behavior - Plesk Migration Tool will migrate only objects it knows about. Since you have some databases and users which are managed through MySQL directly, Plesk does not know anything about it, so they will not be transferred.
You should transfer such databases and users manually with mysqldump.
To create a backup of database with mysqldump you can use the following command:
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin DATABASE_NAME > FILE_NAME.sql
To restore such database run:
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin DATABASE_NAME < FILE_NAME.sql
Also you will need the mysql database which contains grant information. I do not recommend you to blindly transfer it and just re-create users.
Keep in mind that if MySQL version on target server is higher than on source you will need to run mysql_upgrade script to make changes in schema.
Alternatively you can export/import databases through phpMyAdmin which is shipped with Plesk and can be found at Plesk > Tools & Settings > Database Servers.

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 )

Upgrading XAMPP on Windows from very old version: Can I exclude the native tables without loosing important data?

XAMPP has changed from InnoDB to MariaDB some time ago. As I need a newer version of PHP and MySQL I need the new version of XAMPP. Now my database dump of the old XAMPP is very big as all past projects are within this DB.
It looked like I had problems with importing the native mysql tables
information_schema
mysql
performance_schema
phpmyadmin
test
Therefore I did the following in the old xampp installation:
First export all database names except the native ones:
SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN ('mysql','information_schema','performance_schema','phpmyadmin','test');
Second dump all databases except the native ones:
mysqldump -u root > all-dbs.sql --databases db1 db2 .....
In the next step I imported the dump within PHPMyAdmin which seems to work (import still running while writing this).
Now my question is: Do the native tables of mysql contain important data of my old projects or can I safely go on with the new ones?

How do I upload new data-base structure into mysql from my development db?

we've been making changes in the MySQL database, adding tables, columns and so forth and I have a development/staging site and production. All are MySQL, staging and production hosted remote.
How do I export the table structure and bring it into the production environment?
I have been using phpMyAdmin to administer it to date.
On local dev system:
$ mysqldump -u username -p databasename > export.sql
On remote system:
$ mysql -u username -p databasename
mysql> source pathto/export.sql
Check out mysqldump, a command line tool that comes with MySQL, here:
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
Using it, you can take a snapshot of both the structure and the data of your database and import it elsewhere.

Import/Exporting databases from one machine to another

I have two PCs, one is Ubuntu 8.10 and the other Ubuntu 9.10. On the Ubuntu 8.10, i have a few databases in phpmyadmin which i would like to copy across to the Ubuntu 9.10 phpmyadmin(which has no databases).
I'm not sure if i'm on the right path but here's what i think i should do:
Export the databases onto Ubuntu 8.10. And copy those files(.sql) and paste them onto the Ubuntu 9.10 PC in a folder or something. Then import these .sql files into phpmyadmin on Ubuntu 9.10.
Is there a better way to do Copy the databases across?
Thanks.
From the main screen of phpMyAdmin (visible right after login) there are "Export" and "Import" links. Use these facilities to export your database (to a file on your computer) and then to import that file on the destination host.
Alternatively, if you have shell access to both machines, you could use the command mysqldump:
mysqldump --password=PASSWORD -u root DATABASE > INSERT_STATEMENTS
and then simply create all databases on the destination host with
mysql -u root --password=PASSWORD < INSERT_STATEMENTS
There's als MySQL Administrator that comes in the MySQL GUI Tools package. Since you've got access to both machines this is probably the easiest solution. Although I believe it just uses mysqldump, the GUI makes it a lot easier.