Exporting database dump via phpMyAdmin to MS SQL - mysql

When I use the phpMyAdmin export, it has an option for MS SQL export compatibility. However, the resulting file includes many non-MS SQL compatible items, such as mediumtext and enum datatypes. How do I work around this issue?

mysqldump --compatible=mssql -uroot -p some_database > output_file_mssql.sql
vs
mysqldump -uroot -p some_database > output_file.sql
Looking at the difference between the two files will show you some things to check out.
I hope that helps some.

If you are unable to locate a way for phpMyAdmin to generate an exported file of the correct format, then you'll have to edit the resulting exported file to make it compatible with MS SQL. You may need to use regular expressions to, for example, replace ENUM datatypes.
If you find that you have to export data frequently, you may find that writing a short text processing script that you can re-run as needed will save you time.
Oh, and take care that your text editor or favorite scripting language can properly handle the character encoding of the file generated by phpMyAdmin.

This documentation seems pretty conclusive - http://www.waynezim.com/2010/03/how-to-export-mysql-database-to-mssql-using-phpmyadmin/

Related

Export masked data with mysqldump from a mariadb database

Some collegues asked me to extract certain data from a Mariadb db with mysqldump and to mask some of them due to their sensibility; so basically I should obtain a "masked" dump.
Is it possible to do this kind of thing?
I didn't find any clause to add to the command or tool to do it.
I just found this tool https://mariadb.com/resources/blog/sensitive-data-masking-with-mariadb-maxscale/ but at first glance, looks like I would be forced to mask data FOR EVERYONE and I can't do it because is a production db.
Any suggestion is absolutely welcome. :)

importing a database into phpmyadmin #1044 - Access denied for user Can't Edit File

I'm right now trying to upload a 1.3gig sql text file to phpmyadmin and each time I do it I get the following issue.
my issue
I've already tried splitting the file and editing out the CREATE DATABASE line but each time I try opening it in notepad, notepad++ and emeditor I get a bunch of random characters, clearly there's an issue with the encoding. It's not something I can easily export since another company handles that and I have no access to it. I don't care how my SQL text file is opened, I just need a way to view it and I can't find one.
Thanks for any help you can provide!
ISSUE IS SOLVED!!!
You're trying to create and then write the database named mysql. You Can't Do Thatâ„¢.
You should treat that database, and the information_schema and performance_schema databases, as readonly. They provide ways to retrieve information about the server via SELECT operations. Except in very specific special cases, writing those databases will at best do nothing and at worst trash your server. MySQL tries to prevent you from doing damage by throwing privilege errors when you try to alter those databases.
In a comment you mention that you are confident you can fix an issue with your system via the mysql data base. With respect, that's entirely incorrect.

Possible to save and list queries in MySQL?

I have a database and have saved the code on a separate document for a number of queries - is there anyway of saving them as part of the database as some kind of list so that they can be clicked on to run them rather than keeping on having to paste the code in?
I realise that there are various Reports systems available to purchase on line, but this is a small database and a one-off, and they look complicated and not worth the trouble.
Is there anyway of streamlining this?
If I understand correctly you can write those sql queries to a script-or bunch of script files- file and directly run on mysql without copy/paste.
mysql -u user -ppass < script.sql

Exporting all data from MySQL database to spreadsheets

So, I've got a MySQL database consisting of a bunch of tables that I want to give to my uncle.
Problem is, he doesn't know much about computers, so I can't just hook him up with the database.
Instead, I would like to extract all the data from the database into a more readable format, e.g. Excel spreadsheets.
I've tried mysqldump, but that just gives me a *.sql file which doesn't help much.
Any ideas?
If you only have command line, this answer explains how to dump into a tab delimited and this answer how to dump into a comma delimited file. You can then import the tab delimited file into Excel.
Alternatively, you can use phpMyAdmin to export to *.csv if you have PHP.
PHPmyadmin allows you to Export to many different formats - why don't you access your database through that?

Save sql code used for creating database

I am using windows terminal to create a simple database. I was wondering is the code used saved anywhere or do I have to save it? And how? I need to save the code I used for creating the database that's why I'm asking.
If you are talking about SQL Server, you can script out the database you created - just right click on the database in Management Studio, and script away!
Yes, you should save your work. Most tools don't save your indentation, they often format the sql in their own way - sometimees as
CREATE TABLE user#host.dbname.table AS ...
so it works to reconstruct your database, but isn't well readable. The worst thing I ever saw was what MsAccess did to my Input in the SQL-Window (but it was 15 years ago).
In MySQL you can use SHOW CREATE TABLE xxx to see the definition for your table(s).
Using mysqldump can help you create an sql file which you can later run to create a DB identical to yours.
It has many useful options you can read about here.
For your case it seems you need the schema only, without the data - see a how-to here. Basically all you need is the command:
mysqldump --no-data -u Username -pPassword mydatabase