Can't copy schema data in /mySql Workbench 6.0 - mysql

I've just installed MySql Workbench 6.0.09 on recommendation. The main reason was to copy my Wordpress database which is stored in MySql.
I'm using the import/export function with a single file, however it doesn't seem to populate the new schema whether I create it before hand or let the process create it.
I've read somewhere that this cross schema copy doesn't work in older versions, but I'm unsure whether this is still the case, i'm doing something wrong, or there is a permissions issue. It seems unlikely that I'm doing something wrong as there is literally a few clicks to deal with.
Anyone advise?

From the discussion above I conclude this question is about creating a duplicate of an existing database using MySQL Workbench. There are several possible approaches for this scenario:
Createa a dump of your source server using the Data Export feature in MySQL Workbench:
. Then restore that dump on the target machine (via Data Import/Restore).
Do a quick an easy shot by using Schema Transfer Wizard. See menu -> Database -> Schema Transfer Wizard...
Start a normal MySQL to MySQL migration using the Migration Wizard under the same menu item. This would also allow to migrate to different MySQL versions.

I didn't find an answer to this however, I did work out a solution.
1) I took a backup of the existing database.
2) I edited the script produced by the backup. I edited the database name on 2 lines at the top of the script then ran it.

Related

Best approach to working with multiple developers and databases

I've been working on a project for a couple of months now with a few other developers and it has got to the point where we all have different changes to the DB we are working with, but all of the changes are local, meaning the server is out of sync with all of our local changes.
What is the best way to handle this? At the moment I tried to basically export my database from my local PC with phpMyAdmin and import that .sql file into the database on the server but as some of the tables already exist on the server it just gives out an error...
Would I have broken my database on the server by trying to import that sql file?
What do I do?
Ok so here's what I would do in your position...
Use this tool: http://www.clevercomponents.com/downloads/dbc/dbcdownload.asp
With the database compare tool, it should identify the differences in structure between two databases.
This generates an SQL file which will alter the target (your server) database to match the master (your local).
Always backup your target database before attempting something like this, just in case it goes wrong.

Where can I find my mySQL database (using locate doesn't help)?

First ever Stack Overflow post, thanks for your time. Any constructive criticism on how to post better, please just let me know. I have done a search on my query and have found similar posts, but I was unable to use the information within them to resolve my problem.
I have created a mysql database using the terminal window in my Ubuntu system (which I am also new to, having been a lifelong windows user). I used the following code in the terminal window:
$ mysql -u root -p
Then once in mysql, I did the following
CREATE DATABASE securities_master;
USE securities_master;
I created a user and tables in the database using some other code, that doesn't seem relevant here, so I won't bother posting. However, I then decided I would like to take a look at the tables in the database, so I downloaded an SQLite browser. It was at this point that I realized I could not find my database file.
I tried to find the answer on previous stack overflow posts, and tried the suggestions of:
locate sqlite
locate .db
locate .sqlite
locate securities_master
But unfortunately, none of these showed the file I was looking for. The only place I can think of would be what is called the 'root' directory in my computer, but the Ubuntu file manager system won't let me view it because it says I don't have permissions. Is this where it might be?
Could someone shed some light on where I might be able to find this file/database? I know it is definitely there because if I try to CREATE it again, I get the message that it can't because it already exists.
Thanks again.
sqlite and mysql are two different databases. You can't use sqlite on a mysql database. sqlite is a single-file database, in which users just open the file and read and write to it, while mysql is a more traditional relational database system with a server and a client, where the server manages the database (which is generally in a directory of files), while the client just connects to the server.
Where the mysql database is located my depend on your system, but it's usually in /var/lib/mysql. You can look in /etc/mysql/my.cnf for the configuration file, which should have a datadir option that refers to where the actual data for the database is stored.
You can check my.ini file to see where the data folder is located.
Usually there is a folder {mysqlDirectory}/data
MySQL data storage:
Commands.frm
Commands.myd
Commands.myi
The *.frm files contain the table definitions. Your *.myi files are MyISAM index files. Your *.myd files contain the table data.
as mentioned in the answer before mine, mysql and sqlite are two different systems.
You mention you used the cmd line mysql to create the database and then wanted to view the tables. If you're simply trying to see which table are created, in the same command line you used to Create the database you can run show tables;
If you're after a GUI for this, we'd need a bit more context. Is this ubuntu system a remote server, or are you using the desktop version?
You say you're a long time windows user, If you're using windows locally, I personally like SQLWorkbench for accessing my remote mysql servers.
EDIT: I just re-read your post and realised you're using local ubuntu desktop so me mentioning remote was silly, my bad! However, SQLWorkbench does have a ubuntu version at https://dev.mysql.com/downloads/workbench/

Migrating MS SQL to MySQL using MySQL Workbench causes a permission error

I have been working on this all day and now I'm stuck, so hopefully someone out there can help me :)
The challenge.
Migrate data from MS SQL to MySQL.
The MS SQL I received as a bak file, which I restored using SQL server management studio on a PC with Windows 7 Home edition.
I have created a source MySQL database on a webserver, running LAMP.
The solution (maybe)
I'm currently trying to convert the database, initially just one table for testing, using MySQL Workbench with the database->migrate wizard, but now I'm stuck at the Bulk Data Transfer. I would expect this step to create the table in my MySQL database and transfer the data, but that never happens.
For the source I choose Connection Method = ODBC (native)
No problems connecting to the source and destination databases
I choose to keep schema info as table prefix, so imported tables look like: database.dbo_table_name
Migration step succeeds (migrate selected objects & Generate SQL Create Statements)
The Create statements look like this if I don't edit them
CREATE TABLE IF NOT EXISTS 'restored_database_name'.'dbo_table_name' … I think the 'restored_database_name' part causes a permission error. It does if I type this in the SQL tab directly in phpMyAdmin. Therefore I change it to:
CREATE TABLE IF NOT EXISTS 'dbo_table_name' …
Also per default this is part of the SQL:
DROP SCHEMA IF EXISTS 'restored_database_name';
CREATE SCHEMA IF NOT EXISTS 'restored_database_name …
I think this also causes some permission issues, so I commented these out.
In the next step I uncheck the 'Create schema in target RDBMS' since I don't think I want this.
The problem:
Nothing interesting for the next steps, but then at the "Bulk data Transfer" I get this error:
ERROR: 'restored_database_name'. 'dbo_database_name': mysql_stmt_prepare: SELECT command denied to user 'mysql_user_name'#host' for table 'dbo_database_table_name.
Finished copying 0 rows.
I think the error is somehow related to permissions on the destination database. I wonder if it is possible to make sql file, not just with the create table commands, but also with INSERT commands so I could just take the sql and import it using command line or phpmyadmin.
I'm using Workbench 5.2 CE
Any help is appreciated
I've seen that you have made your way into the Workbench's Migration Wizard. Maybe you're just missing something so I suggest you to review this blog so you can verify your steps: How-To: Guide to Database Migration from Microsoft SQL Server using MySQL Workbench.
Unfortunately you can't use the Migration Wizard data copy command line utility to generate the SQL file with all the inserts, but I'm pretty sure you can get this from MS SQL Server Management Studio and it should pretty much work for MySQL without modifications (or with minor modifications).

SQLite and MySQL, will the conflict?

I just joined a project where they have been using SQLite. I am more comfortable using MySQL with PHPMyAdmin. If I install phpMyAdmin and work with that will it do any damage?
It is a php project. They have alot of code (sloppy code thats so hard to figure out) for accessing a SQLite db. I dont want to effect that but I want to add some new tables to a new db using mysql and phpmyadmin which i am yet to set up because I'm afraid it will break the code written for the SQLite db
.
Are you talking merely about installing PHPMyAdmin to manage a SQLite database? That won't work, since both use completely different API's to be accessible through PHP.
Or do you wish to swap the SQLite database with MySQL and then use PHPMyAdmin to manage the database? That'll work, as long as the project supports both SQLite and MySQL.
Is it a PHP project? Probably not - mysql_-prefixed methods only work with MySQL as far as I know, and SQLite and MySQL don't listen on the same port by default, do they?
You need to work with what is deployed. If the project is using Sqlite, then use that. Databases are not all equal. If you use something different, your code might not even run on the production databases.
first of all, if you don't want affect, create a branch on github then from work this branch ..
you can also dump all table of this sqlite database to a sql file, then import this file to your phpAdmin, will create the table, since this both manager uses sql language ... just remove some ligne of code that are not compatible with mysql on sql file that you dump data from sqlite dabtase .....
here is the code for dump a sqlite database ....
first select the database on terminal on your project director
sqlite3
./open DATABASENAME
.output YOURSQLFILENAME.sql
.dump
.quit
at this stage you already have your database in a sql file
then use php admin to import this file
if it show some error, just try to remove somecode that aren't compatible with mysql on sqlfile.

How to import a SQL Server .bak file into MySQL?

The title is self explanatory. Is there a way of directly doing such kind of importing?
The .BAK files from SQL server are in Microsoft Tape Format (MTF) ref: http://www.fpns.net/willy/msbackup.htm
The bak file will probably contain the LDF and MDF files that SQL server uses to store the database.
You will need to use SQL server to extract these. SQL Server Express is free and will do the job.
So, install SQL Server Express edition, and open the SQL Server Powershell. There execute sqlcmd -S <COMPUTERNAME>\SQLExpress (whilst logged in as administrator)
then issue the following command.
restore filelistonly from disk='c:\temp\mydbName-2009-09-29-v10.bak';
GO
This will list the contents of the backup - what you need is the first fields that tell you the logical names - one will be the actual database and the other the log file.
RESTORE DATABASE mydbName FROM disk='c:\temp\mydbName-2009-09-29-v10.bak'
WITH
MOVE 'mydbName' TO 'c:\temp\mydbName_data.mdf',
MOVE 'mydbName_log' TO 'c:\temp\mydbName_data.ldf';
GO
At this point you have extracted the database - then install Microsoft's "Sql Web Data Administrator". together with this export tool and you will have an SQL script that contains the database.
MySql have an application to import db from microsoft sql.
Steps:
Open MySql Workbench
Click on "Database Migration" (if it do not appear you have to install it from MySql update)
Follow the Migration Task List using the simple Wizard.
I did not manage to find a way to do it directly.
Instead I imported the bak file into SQL Server 2008 Express, and then used MySQL Migration Toolkit.
Worked like a charm!
In this problem, the answer is not updated in a timely. So it's happy to say that in 2020 Migrating to MsSQL into MySQL is that much easy. An online converter like RebaseData will do your job with one click. You can just upload your .bak file which is from MsSQL and convert it into .sql format which is readable to MySQL.
Additional note: This can not only convert your .bak files but also this site is for all types of Database migrations that you want.
Although my MySQL background is limited, I don't think you have much luck doing that. However, you should be able to migrate over all of your data by restoring the db to a MSSQL server, then creating a SSIS or DTS package to send your tables and data to the MySQL server.
hope this helps
I highly doubt it. You might want to use DTS/SSIS to do this as Levi says. One think that you might want to do is start the process without actually importing the data. Just do enough to get the basic table structures together. Then you are going to want to change around the resulting table structure, because whatever structure tat will likely be created will be shaky at best.
You might also have to take this a step further and create a staging area that takes in all the data first n a string (varchar) form. Then you can create a script that does validation and conversion to get it into the "real" database, because the two databases don't always work well together, especially when dealing with dates.
The method I used included part of Richard Harrison's method:
So, install SQL Server 2008 Express
edition,
This requires the download of the Web Platform Installer "wpilauncher_n.exe"
Once you have this installed click on the database selection ( you are also required to download Frameworks and Runtimes)
After instalation go to the windows command prompt and:
use sqlcmd -S \SQLExpress (whilst
logged in as administrator)
then issue the following command.
restore filelistonly from
disk='c:\temp\mydbName-2009-09-29-v10.bak';
GO This will list the contents of the
backup - what you need is the first
fields that tell you the logical names
- one will be the actual database and the other the log file.
RESTORE DATABASE mydbName FROM
disk='c:\temp\mydbName-2009-09-29-v10.bak' WITH MOVE 'mydbName' TO
'c:\temp\mydbName_data.mdf', MOVE
'mydbName_log' TO
'c:\temp\mydbName_data.ldf'; GO
I fired up Web Platform Installer and from the what's new tab I installed SQL Server Management Studio and browsed the db to make sure the data was there...
At that point i tried the tool included with MSSQL "SQL Import and Export Wizard" but the result of the csv dump only included the column names...
So instead I just exported results of queries like "select * from users" from the SQL Server Management Studio
SQL Server databases are very Microsoft proprietary. Two options I can think of are:
Dump the database in CSV, XML or similar format that you'd then load into MySQL.
Setup ODBC connection to MySQL and then using DTS transport the data. As Charles Graham has suggested, you may need to build the tables before doing this. But that's as easy as a cut and paste from SQL Enterprise Manager windows to the corresponding MySQL window.
For those attempting Richard's solution above, here are some additional information that might help navigate common errors:
1) When running restore filelistonly you may get Operating system error 5(Access is denied). If that's the case, open SQL Server Configuration Manager and change the login for SQLEXPRESS to a user that has local write privileges.
2) #"This will list the contents of the backup - what you need is the first fields that tell you the logical names" - if your file lists more than two headers you will need to also account for what to do with those files in the RESTORE DATABASE command. If you don't indicate what to do with files beyond the database and the log, the system will apparently try to use the attributes listed in the .bak file. Restoring a file from someone else's environment will produce a 'The path has invalid attributes. It needs to be a directory' (as the path in question doesn't exist on your machine).
Simply providing a MOVE statement resolves this problem.
In my case there was a third FTData type file. The MOVE command I added:
MOVE 'mydbName_log' TO 'c:\temp\mydbName_data.ldf',
MOVE 'sysft_...' TO 'c:\temp\other';
in my case I actually had to make a new directory for the third file. Initially I tried to send it to the same folder as the .mdf file but that produced a 'failed to initialize correctly' error on the third FTData file when I executed the restore.
The .bak file from SQL Server is specific to that database dialect, and not compatible with MySQL.
Try using etlalchemy to migrate your SQL Server database into MySQL. It is an open-sourced tool that I created to facilitate easy migrations between different RDBMS's.
Quick installation and examples are provided here on the github page, and a more detailed explanation of the project's origins can be found here.