Add large files (exe, dlls, xmls) into cells of tables in mysql Database - mysql

If I want to store files like exe, dll and xml large files in a cell of a table inside a database, is it possible to do?
If yes, how can it be done? and is it common practice to do so?
I am using mySQL database using ampps.

yes you can use blob type column to store files in mySql but this is not recommended when thousands of file will stored in db then it is difficult to manage database. you should create repository some where in server and create file with database id.

Related

how to copy all the database tables from one schema to another on the same server?

I am trying to copy all the MYSQL database tables present in one schema to another using MYSQLworkbench?I read on other posts about using Dataimport
but its not clear as to how to use it?can anyone provide pointers on how to do it?is there a better tool to do this?
The data import/export wizards are pretty straight forward: https://dev.mysql.com/doc/workbench/en/wb-admin-export-import-management.html. What you need is to specify the source for the dump you made (either from a folder or a self contained dump file). Then specify a different schema to import in and off you go.

how to prevent mysql data file being copied out

Just wondering is there any ways to prevent mysql data files being copied by others.
I am a developer with mysql as database, i want to protect my tables so no one are possible to copy the table and used it with their own program, or simply to put i don't want other to see my table design.
As we are aware that mysql contains 3 files for each table in the mysql folder, so anyone can copy those files and put it into their own server.
There's no MySQL specific way to achieve that.
If you mean something like file encryption, MYSQL doesn't support that natively.
Have a look at this 3rd party product:
http://www.vormetric.com/products/encryption/database-encryption
But as zerkms correctly commented:
if you have admin/root permissions on a machine - you can do whatever
you want.

load many txt files to mysql db

I want to store 7000 records consisting of txt files as datatype BLOB in my DB using workbench.
But:
1. I don't know how to do it automatically? Should I put all the files in one catalogue and then write a script to take them one by one and insert in the adequate rows?
2. I am not sure if BLOB is fine for this type of file storage? Later I want to connect my DB with GUI so after clicking, it should be possible to open each txt file in new window.
Could you advice me how to solve my problem?
You should write a script, yes. If it's hard for you to put them all in one folder I think there are scripts and tools to do this.
You can use C#, PHP or any other lang to scan those files and then insert them into the database.
Bunch of tutorials:
http://www.csharp-examples.net/get-files-from-directory/
Inserting record in to MySQL Database using C#
http://www.codeproject.com/Articles/43438/Connect-C-to-MySQL
http://net.tutsplus.com/articles/news/scanning-folders-with-php/
http://www.homeandlearn.co.uk/php/php13p3.html
Blob should do, takes around 20 megabytes of text.

MySQL database changing data table paths or location?

I'm using MySQL Workbench for Windows, is there a way to change the path of where MySQL data is stored? For instance, I would like to store some data in C: drive and I would like to store other data in another drive (E:) or something?
Thanks
All data is supposed to be stored under a single "datadir" in MySQL, but you can get creative with symbolic links so the data for a given database can live elsewhere.
See http://dev.mysql.com/doc/refman/5.1/en/windows-symbolic-links.html

How to upload data from zip file to MySQL database using phpMyAdmin?

I have a client who got a zipped file that has all the database they had in the SaaS app they were using. Now, we have a similar app but our column names are different (obviously) and in some cases we have less columns. So, now i want to upload all this data to my database but i am not sure how to do it?
I run phpmyadmin on the servers.
Extract the file on your desktop.
Login to your phpMyAdmin account.
Click the Import tab.
Select the file to import, file format, ect. and click Go.
Browse through the structure of the imported database to the columns of interest. For each column, click the pencil icon to edit the column (i.e. rename it), or click the X icon to delete it.
To merge data sets, after importing the tables, you would need to run your own query in the SQL tab to merge the data sets.
That are two different tasks in one question,
phpMyAdmin is able to import ZIP-files directly – you don't need to extract them on your local machine. Also be aware of max upload sizes and maximum script execution times, when importing huge database dumps.
To map an existing database to another structure involves a lot of manual work, like renaming tables and columns and copying data from on table to another.I would suggest, you import the old/original database to some "working copy" database and have your new database separate. That way you can use MySQL-features (INSERT INTO new_db.YX … SELECT XY_a FROM old_db.XY) to copy the data where it should go.
Well first you need to take a look at the data files and see how the columns/tables differ. After you sort that out you can go about about figuring out how it insert the data. If the files are large and there are quite a few i wouldnt use phpmyadmin. I'd ssh into the box and use the command line client or set the DB up for remote access and use a local copy of the client.
If youre lucky you won't have to do any processing on the data and you just map values from the old columns to the new columns as part of you LOAD DATA INFILE statement. Whatever you do youll want to test all this on a dummy db(s) first before you go running it in a live environment.