[mysqld] default_authentication_plugin=mysql_native_password port = 3306 local_infile=On secure-file-priv = ""et procédez à l'importation LOAD DATA via le Console MySQL comme expliqué ici [www.smf-fr.com]
secure_file_priv="D:/wamp64/tmp"par
;secure_file_priv="D:/wamp64/tmp" secure_file_priv="" local_infile=OnAprès sauvegarde du fichier modifié, il faudra relancer Wampserver.
# To allow LOAD DATA LOCAL INFILE php_admin_value mysqli.allow_local_infile 1 </Directory>
# ------------------------------ # # Load data local infile # # ------------------------------ # local-infile = 1 secure-file-priv = E:/30.MySql loose-local-infile = onen ce qui concerne votre commande, elle a évolué et actuellement, on ne met plus "local" dans "LOAD DATA INFILE".
\N;"10/5/2014 15:33:17";"web" 125;"15/5/2014 23:53:59";"alpha\; beta\; gamma" -247;\N;"zéro"
-------------- START TRANSACTION -------------- -------------- SHOW VARIABLES LIKE 'secure_file_priv' -------------- +------------------+--------------+ | Variable_name | Value | +------------------+--------------+ | secure_file_priv | E:\30.MySql\ | +------------------+--------------+ -------------- DROP DATABASE IF EXISTS `base` -------------- -------------- CREATE DATABASE IF NOT EXISTS `base` DEFAULT CHARACTER SET `latin1` DEFAULT COLLATE `latin1_general_ci` -------------- -------------- DROP TABLE IF EXISTS trav -------------- -------------- CREATE TABLE `trav` ( `id` integer unsigned not null auto_increment primary key, `col_num` integer null default null, `col_date` datetime null default null, `col_char` varchar(255) null default null, `col_vide` varchar(255) null default null ) ENGINE=InnoDB DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci` ROW_FORMAT=COMPRESSED -------------- -------------- LOAD DATA INFILE 'E:/30.MySql/40.Load/Ex_01/fichier.txt' INTO TABLE `trav` CHARACTER SET latin1 FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n' IGNORE 0 LINES (@F1, @F2, @F3) set col_num = trim(@F1), col_date = str_to_date(trim(@F2), '%d/%c/%Y %H:%i:%s'), col_char = trim(@F3), col_vide = '...' -------------- -------------- select * from `trav` -------------- +----+---------+---------------------+--------------------+----------+ | id | col_num | col_date | col_char | col_vide | +----+---------+---------------------+--------------------+----------+ | 1 | NULL | 2014-05-10 15:33:17 | web | ... | | 2 | 125 | 2014-05-15 23:53:59 | alpha; beta; gamma | ... | | 3 | -247 | NULL | zéro | ... | +----+---------+---------------------+--------------------+----------+ -------------- COMMIT -------------- Appuyez sur une touche pour continuer...
Ok, mais, ça vous ne le faites pas dans la console avant d'envoyer les LOAD DATA !Citation
Stephsteph
Dans nos pages php on a déjà le code:
$connexion = new PDO('mysql:host=' . $PARAM_hote . ';dbname=' . $PARAM_nom_bd, $PARAM_utilisateur, $PARAM_mot_passe, array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"winking smiley);
mysql> SHOW VARIABLES LIKE 'char%'; +--------------------------+-------------------------------------------------+ | Variable_name | Value | +--------------------------+-------------------------------------------------+ | character_set_client | cp850 | | character_set_connection | cp850 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | cp850 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | E:\wamp64\bin\mysql\mysql8.0.22\share\charsets\ | +--------------------------+-------------------------------------------------+ 8 rows in set (0.01 sec)On voit bien que la connexion client est cp850 et pas utf8.
mysql> SET NAMES UTF8; Query OK, 0 rows affected, 1 warning (0.00 sec)Et là, la connexion client est bien vue comme utf8
mysql> SHOW VARIABLES LIKE 'char%'; +--------------------------+-------------------------------------------------+ | Variable_name | Value | +--------------------------+-------------------------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | E:\wamp64\bin\mysql\mysql8.0.22\share\charsets\ | +--------------------------+-------------------------------------------------+ 8 rows in set (0.00 sec) mysql>