Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Import huge list into mysql database

Hey everyone,

i got my hands on "collection #1" password list.
since the collection is split into hundreds of files i am looking for a way to search trough all of them.

My idea at the moment is to import all lists into a mysql database and then write a simple script to search inside the database.

My problem is im not sure whats the best way to import this huge data.
We are talking here about 100 millions of lines.

First try: write a script that parses line by line of every file and write them into the database => of course takes ages

Second try: a php script using the LOAD FILE command to load whole files into the database => works okay but takes longer the larger the database gets

Third: using "LOAD FILE" via comand line with mysql => faster but also same problem as second try

so the main problem is: The larger the database gets the longer it takes to add new data.
For example first file with 100.000 lines get imported in 8 seconds... the third file with 100.000 lines already takes 40 seconds... 10'th file with 100.000 lines takes about 6 minutes...


do you have any ideas how to import the data?
[Image: ln2sPXQ.gif]
Use mysql cli to import, more faster and stable than GUIs, increase mysql cnf timeouts, max file size etx

[Image: 26yROWk.gif]
(Feb 10, 2019 06:51 AM)Digital Wrote:  Use mysql cli to import, more faster and stable than GUIs, increase mysql cnf timeouts, max file size etx

like in sayed i already tried thie cli to import..
its way faster but it gets slower with every file i try to import
im am on default settings right now.. anyting i can tweak?
i will take a look at cnf timeouts, max file size is not an issue with cli right?
[Image: ln2sPXQ.gif]
(Feb 10, 2019 06:55 AM)RayGenWurm Wrote:  like in sayed i already tried thie cli to import..
its way faster but it gets slower with every file i try to import
im am on default settings right now.. anyting i can tweak?
i will take a look at cnf timeouts, max file size is not an issue with cli right?

How about Load Data Infile? That would be useful

[Image: 26yROWk.gif]
you better use language that can use threading to do it
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
Well, if you're uploading millions of files and want to be able to easily search through them, MySQL is proving to be slow and it doesn't seem like the data is relational at the moment.

Therefore, I suggest using a distributed search engine. A search engine might seem a bit overkill, but solely because you have large amounts of data, and you have a requirement to be able to retrieve them quickly, I think you'll benefit from one.

A great search engine that I know that has the capabilities to store petabytes of data and can scale very well is Elastic Search. You can search through millions of files in the blink of an eye. It has a bit of a learning curve, but in my opinion, it's the next thing to learn after you've become comfortable with relational databases.
https://www.elastic.co/products/elasticsearch

Alternatively, you can use MongoDB, but I am unsure of it's application as I've never used it before.
It seems like SQL is not the way you want to go with this, especially if you're going to have hundreds of thousands of entries within. Unless you decide to go with a language that allows threading, importing and searching this data will probably take a very long time regardless of how you decide to do it. I would also suggest something like +Haze said, a search engine could be your best bet for something of this application.
If you really wanna do it in PHP here is a link to how to use multithreading in PHP: http://php.net/manual/en/book.pthreads.php


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by Shellcode™Dec 18, 2022 01:53 PM 4 210 Dec 18, 2022 01:53 PM
Last Post: Dialog
[PHP] by DivineProgrammingFeb 15, 2020 01:56 PM 6 187 Feb 15, 2020 01:56 PM
Last Post: DivineProgramming
[Javascript]  by Account of the GodsJul 6, 2018 03:31 PM 2 155 Jul 6, 2018 03:31 PM
Last Post: Two-Ton 21