mysql : Obsolète

Le module mysql n'est plus supporté dans PHP 7.

Trucs vim pour corriger (ancien code de genlist2) vers PDO

:%s#mysql_query($sql, $this->_db)#$this->_db->query($sql)#g
:%s#mysql_fetch_object($qry)#$qry->fetch(PDO::FETCH_OBJ)#g
:%s#mysql_num_rows($qry)#$qry->rowCount()#g
:%s#mysql_real_escape_string(\([^,]\+\), $this->_db)#$this->_db->quote(\1)#g
:%s/@mysql_query($\(\w\+\),$this->_db)/$this->_db->query($\1)/

:%s/$row = mysql_fetch_assoc($qry)/$row = $qry->fetch()/g

:%s/$this->set_error(mysql_error($this->_db), $sql);/$this->set_error($this->_db->errorInfo(), $sql);/
:%s/mysql_insert_id($this->_db)/$this->_db->lastInsertId()/

Erreur

PDO is not load, MYSQL_ATTR_INIT_COMMAND

# debian, could be php7-4, php8...
apt install php7.3-mysql # with pdo_mysql.ini

mariadb can't start

tail -f /var/log/mysql/error.log

158 2020-05-16 14:14:11 6 [ERROR] Column count of mysql.proc is wrong. Expected 21, found 20. Created with MariaDB 100126, now running 100322. Please use mysql_upgrade to fix this error

182 2020-05-16 14:58:23 0 [ERROR] Incorrect definition of table mysql.event: expected column 'sql_mode' at position 14 to have type set('REAL_AS_FLOAT','PIPES    _AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE    ','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES',    'STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER    ','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH','EMPTY_STRING_IS_NULL','SIMULTANEOUS_ASSIGNMENT'), found type set('REAL_AS_FLOA    T','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL    ','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALU
183 2020-05-16 14:58:23 0 [ERROR] mysqld: Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.


2020-05-16 14:58:28 13 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade
2020-05-16 14:58:28 13 [Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name.  Please run mysql_upgrade

systemctl mariadb start