cdmon ensures the security and proper operation of its services. For this reason, certain insecure MySQL functionalities for loading local files in bulk are not available. Below we explain three methods to import data into MySQL.
1.-Import a CSV file into MySQL from PHP
Below is an example PHP script that performs this type of import:
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $import = "INSERT INTO $table (text, number) VALUES ('$data[0]', '$data[1]')"; mysql_query($import) or die(mysql_error()); }fclose($handle);}
You should take the following aspects into account when importing data from PHP:
If any of the limits established in your hosting plan are exceeded, the process will not complete correctly.
2.-Import an SQL file into MySQL from SSH
With SSH access enabled (
How to enable SSH access) on your hosting, you can perform a console import with the following command:
$ cat "archivo_importar.sql" | mysql -u Usuario -p NombreBaseDeDatos
- User: MySQL user.
- DatabaseName: name of the destination database where the queries defined in “archivo_importar.sql” will be executed.
3.-Import an SQL file into MySQL from the Control Panel