How do you insert 10000 rows to mysql in php?
The same way you insert 1 row, just 10,000 times. There are two choices, I'm going to assume you've already connected to mysql and you are prepared to run your query:
- Transactional method: $query = "INSERT INTO foo (column) VALUES (row1), (row2), (row3) ... (row10000);"; mysql_query($query); This is ideal when it is imperative that all rows go into the database. Keep in mind that this method will tie up the database until the entire query is completed.
- Separate queries $query = "INSERT INTO foo (column) VALUES (row1); INSERT INTO foo (column) VALUES (row2); ... INSERT INTO foo (column) VALUES (row10000);"; mysql_query($query); This method will allow other queries to run along side and will not necessarily tie up the database, if it's ok if some rows fail this method is probably ideal.
- Check MySQL Version with V Command. The easiest way to find the MySQL version is with the command: mysql -V…
- How to Find Version Number with mysql Command. The MySQL command-line client is a simple SQL shell with input editing capabilities…
- SHOW VARIABLES LIKE Statement…
- SELECT VERSION Statement…
- STATUS Command.
- Open the MySQL command line.
- Type the path of your mysql bin directory and press Enter.
- Paste your SQL file inside the bin folder of mysql server.
- Create a database in MySQL.
- Use that particular database where you want to import the SQL file.
- Type source databasefilename.sql and Enter.
- Your SQL file upload successfully.
We've handpicked 21 related questions for you, similar to «How do you insert 10000 rows to mysql in php?» so you can surely find the answer!