As a JSON file with lots of lines to pass to MySQL?

Good afternoon there is a JSON database like this:
{"_id":707860,"name":"Hurzuf","country":"UA","coord":{"lon":34.283333,"lat":44.549999}}
{"_id":519188,"name":"Novinki","country":"RU","coord":{"lon":37.666668,"lat":55.683334}}
{"_id":1283378,"name":"Gorkhā","country":"NP","coord":{"lon":84.633331,"lat":28}}
{"_id":1270260,"name":"State of Haryāna","country":"IN","coord":{"lon":76,"lat":29}}
{"_id":708546,"name":"Holubynka","country":"UA","coord":{"lon":33.900002,"lat":44.599998}}

Should be using PHP to move it to mysql. In mysql you have already created a table with columns (id,name,country,lon,lat).
Tell me how to do it?
August 23rd 19 at 10:38
2 answers
August 23rd 19 at 10:40
It is better to do query for each row, and forming the batch query INSERT INTO (...) VALUES (...), (...), ...
It is necessary to consider the maximum length of MySQL query, set variable 'max_allowed_packet'.
Before the script will work it is better to disable all indexes on the table after turn them back on.
August 23rd 19 at 10:42
Thank you to those who tried to help, I wrote code like this:
$connect = mysql_pconnect("localhost","root","") or die ("Cannot connect to MySQL"); // Connect to the mysql database (address, username, password)
 mysql_select_db("weather", $connect) or die ("unable to open table data"); // connect to database (database name, $connect)
 mysql_query("SET NAMES 'utf8'", $connect); // set encoding
 $filename = "template/city.list.json"; // location of json database
 if ($file = fopen($filename, "r")) { // open json file
 while (!feof($file)) { // pass cycle until we reach the end of the file 
 $line = fgets($file, 1024); // return each line of the file
 $data = json_decode($line, true); // decode json array in php array
 $result = mysql_query ("INSERT INTO weather_country (id, name, country, lon, lat) VALUES ('".$data['_id']."', '".$data['name']."', '".$data['country']."', '".$data['coord']['lon']."', '".$data['coord']['lat']."')"); // obtained data recorded in table weather_country.
}
}
 if (isset($result)){ // print the result of the script
 echo "Added to database.";
 } else {
 echo "who hasn't been added to the database.";
 }


If someone knows a more elegant and correct spelling, please share!

Find more questions by tags JSONMySQLPHP