简体   繁体   English

如何通过phpmyadmin在MySQL数据库中存储大量数据?

[英]How to store large amount of data in MySQL database through phpmyadmin?

I have approximately 4 GB(34,000) of JPEG files that I need to store in MySQL table. 我大约需要将4 GB(34,000)JPEG文件存储在MySQL表中。 Each image is of different date varying from 1-jan-1961 to 31-dec-2007. 每个图像的日期不同,从1961年1月1日到2007年12月31日不等。 How should I store these files such that when I enter the specific date between this time interval the corresponding image appears in my localhost server. 我应该如何存储这些文件,以便当我在此时间间隔之间输入特定日期时,相应的图像出现在我的本地主机服务器中。 The MySQL table has following schema ID, date(that is being entered by the user end), file name, type, size.Is there any way I can upload these files(images) in chunk and not one by one. MySQL表具有以下架构ID,日期(由用户端输入),文件名,类型,大小,是否可以通过任何方式将这些文件(图像)成块上传而不是一一上传。

Always use mySQL client to do the bulk uploads, You can use the native mysql client or a PHP client. 始终使用mySQL客户端进行批量上传。您可以使用本地mysql客户端或PHP客户端。 However all these years i didn't have to save a image in MySQL. 但是这些年来,我不必在MySQL中保存图像。 It is hard to manage and have bad effect on the DB performance. 它很难管理,并且对数据库性能有不良影响。

I recommend you to keep only a file URL in the database and have the files elsewhere, it can be local or some other image host. 我建议您在数据库中仅保留文件URL,并将文件保留在其他位置,它可以是本地或其他图像主机。 However with this you need to take care of some stuff of your own 但是与此同时,您需要自己照顾一些东西

  1. Backing up the images separately when you take MySQL backup, as images are no longer in DB 进行MySQL备份时,分别备份映像,因为映像不再存在于数据库中
  2. Handling transactions and rollbacks 处理交易和回滚
  3. Handling deletes 处理删除

If you can manage with your code, I suggest you to move your images out form the database 如果可以使用代码进行管理,建议您将图像从数据库中移出

First, PHPMyAdmin is not a good choice for end-user GUI, it's preferably used as SQL Web client for DB developers and administrators. 首先,对于最终用户GUI而言,PHPMyAdmin并不是一个不错的选择,它最好用作DB开发人员和管理员的SQL Web客户端。

Second, you should not use MySQL to store images, SQL manipulation of big data blobs is quite inefficient compared to direct filesystem access. 其次,您不应该使用MySQL来存储图像,与直接文件系统访问相比,大数据Blob的SQL操作效率很低。 This point has been debated many times on this site : 关于这一点,本网站已被多次辩论:

You should instead : 您应该改为:

  1. use any file transfer command to upload all your files to your web server: rsync, scp, ftp, etc. I'd recommend rsync for further updates and syncing. 使用任何文件传输命令将所有文件上传到Web服务器:rsync,scp,ftp等。我建议使用rsync进行进一步的更新和同步。
  2. use any server side scripting language (PHP, Python, etc.) to parse your uploaded files and reference them in a metadata only table 使用任何服务器端脚本语言(PHP,Python等)来解析您上传的文件,并在仅元数据表中引用它们
  3. build a simple HTML GUI with the same language to give access to the wanted images. 用相同的语言构建一个简单的HTML GUI,以访问所需的图像。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM