Importing MySQL database - mysql

I'm trying to import a mysql database into my grid service account at media temple.
I've made a blank database, but there are already lots of tables there such as:
CHARACTER_SETS
CLIENT_STATISTICS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
ENGINES
EVENTS
FILES
GLOBAL_STATUS
GLOBAL_TEMPORARY_TABLES
GLOBAL_VARIABLES
What are these prexisting tables? How do I get rid of them so I can import my database

It looks like you are looking at the database created by MySQL for its own use, called INFORMATION_SCHEMA.
You have to create a database with CREATE DATABASE YOURNAMEHERE; and then put your database tables in that database.
Check out a good introductory tutorial in MySQL, like http://dev.mysql.com/doc/refman/5.1/en/tutorial.html

Related

MySql lost table metadata after exporting the database, how to export mysql schema

I'm using MySQL for few months and created lots of tables and procedures using MySQL Workbench (8.0). I recently bought a new laptop and exported the old database and imported to the new laptop. But I lost all the metadata of tables and procedures. I need to know the create date of a table and when was it last modified. But it looks to me that the metadata(information_schema) was not included with the export. Is there a special way to export the metadata too or to include information_schema with the data export?
Thanks for looking at my question.
UPDATE: I found that mysql schema contains all the metadata information, but I can't see that in MySQL Workbench 8.0. I found in other posts that the mysql schema is very much exists but is hidden in the Workbench. So how will I export it? Is there any harm in moving mysql schema from one server to the other?
If you didn't backup and restore the mysql schema, then data like CREATE_TIME and UPDATE_TIME are likely lost or have changed.
Backing up INFORMATION_SCHEMA doesn't make sense, since the tables are mostly views on internal system tables.

How to find a speicifc entry in tables in a database mysql?

I have a database wordpress consisting a lot of tables. I am looking for a certain entry 20.22.31.44. What is the best way to return the table and column if this entry exists?
You can dump your database data (SQLDump) into a file and search through it's content.
You may also use a Database Management system (i.e. Workbench, PHPMyAdmin) to perform that global search for you. See related.

SQL database backup and restore on user id

I have a database which contains details about user information.The database contains 20 tables with users specific details.Every table contains user foreign key. I want to be able to backup specific user data from the database and restore the backup. Is it possible to restore the backup on a different database that has same tables. I am working on this but not able to find a documentation or article on this. If you could help me on this if doing this is possible. Thank you in advance
You need to write some SQL to export the data. You can use a number of techniques for example:
Gather data using views, stored procedures or a combination of both.
Export data using linked servers, import export or SSIS.
There is no backup and restore functionality for a subset if data.
(p.s. This is for SQL Server. You have three different database engines in your tags.)

Combine several mssql database to one mysql with php

We are handling a data aggregation project by having several microsoft sql server databases combining to one mysql database. all mssql database have the same schema.
The requirements are :
each mssql database can be imported to mysql independently
before being able to import each record to mysql we need to validates each records with a specific createrias via php.
each imported mssql database can be rollbacked. It means even it already imported to mysql, all the mssql database can be removed from the mysql.
we would still like to know where does each record imported to the mysql come from what mssql database.
All import process will be done with PHP .
we have difficulty in many aspects. we don't know what is the best approach to solve our problem.
your help will be highly appreciated.
ps: each mssql database has around 60 tables and each table can have a few hundred thousands .
Don't use PHP as a database administration utility. Any time you build a quick PHP script to transfer records directly from one database to another, you're going to cause yourself a world of hurt when that script becomes required for production operation.
You have a number of problems that you need solved:
You have multiple MSSQL databases with similar if not identical tables.
You have a single MySQL database that you want to merge the data into.
The imported data must be altered in a specific way before being merged.
You want to prevent all duplicate records in your import.
You want to know what database each record originally came from.
The solution?
Analyze the source MSSQL databases and create a merge strategy for them.
Create a database structure on the MySQL database that fits the merge strategy in #1, including all the new key constraints (like unique and foreign keys) required for the consolidation.
At this point you have two options left:
Dump the data from each of the source databases into raw data using your RDBMS administration utility of choice. Alter that data to fit your merge strategy and constraints. Document this, and then merge all of the data into your new database structure.
Use a tool like opendbcopy to map columns from one database to another and run a mass import.
Hope this helps.

How to generate SQL queries

I am using phpMyAdmin to create database tables and fields. I have 100's of tables in a single database. Now I need to make the same on few more servers.
I feel it's too hard to write SQL queries to create that database. Is there any reverse process to generate an SQL query file from phpMyAdmin or anyother tool? I want to create a database in a GUI, and I need the SQL query for my database. Is there any tool to generate it automatically?
If I understood you correctly, you want to export a database (with many tables) using phpMyAdmin, and then import it and use it on another server.
Yes. You can do that.
Select the database on the left-hand side in phpMyAdmin and then:
Export -> Select All Tables -> Adjust Options -> Go.
You are going to get <youdatabasename>.sql file, with all the table definitions inside. Then you can import it in another phpMyAdmin or other database handler.
You can use mysqldump to do this. Then --nodata switch should do what you want.