We have an old server that until yesterday was running a 2016 version of Ubuntu. The server was super fast (providing a complex page in less than 1 second). As we needed PHP8.2, we decided to upgrade to Ubuntu22.
After the upgrade the system is very slow and the same page take about 30 seconds to generate!!!!
After investigation I believe the problem is due to MySQL. Prior to upgrade our database was as follow:
-- MySQL dump 10.13 Distrib 5.7.33, for Linux (x86_64)---- Host: localhost Database: website-- -------------------------------------------------------- Server version 5.7.33-0ubuntu0.16.04.1/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;/*!40101 SET NAMES utf8 */;/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;/*!40103 SET TIME_ZONE='+00:00' */;/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;---- Table structure for table `articleBookmarks`--DROP TABLE IF EXISTS `articleBookmarks`;/*!40101 SET @saved_cs_client = @@character_set_client */;/*!40101 SET character_set_client = utf8 */;CREATE TABLE `articleBookmarks` ( `bookmarkId` int(11) NOT NULL AUTO_INCREMENT, `userId` int(11) DEFAULT NULL, `articleId` char(16) DEFAULT NULL, `category` int(11) DEFAULT NULL, `addDate` datetime DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`bookmarkId`)) ENGINE=InnoDB AUTO_INCREMENT=99 DEFAULT CHARSET=latin1;/*!40101 SET character_set_client = @saved_cs_client */;
after upgrade I have
-- MySQL dump 10.13 Distrib 8.0.36, for Linux (x86_64)---- Host: localhost Database: website-- -------------------------------------------------------- Server version 8.0.36-0ubuntu0.22.04.1/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;/*!50503 SET NAMES utf8 */;/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;/*!40103 SET TIME_ZONE='+00:00' */;/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;---- Table structure for table `articleBookmarks`--DROP TABLE IF EXISTS `articleBookmarks`;/*!40101 SET @saved_cs_client = @@character_set_client */;/*!50503 SET character_set_client = utf8mb4 */;CREATE TABLE `articleBookmarks` ( `bookmarkId` int NOT NULL AUTO_INCREMENT, `userId` int DEFAULT NULL, `articleId` char(16) DEFAULT NULL, `category` int DEFAULT NULL, `addDate` datetime DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`bookmarkId`)) ENGINE=InnoDB AUTO_INCREMENT=135 DEFAULT CHARSET=latin1;/*!40101 SET character_set_client = @saved_cs_client */;
It seems that ubuntu decides to change/convert the character set from utf8 to utf8mb4 without asking!
As a result the database display all emoji and spacial symbols wrongly. For example the smile emoji is displayed now as "😂".
In addition I cannot insert anymore records in the database. I receive the following error:
[Tue Mar 26 15:27:25.623713 2024] [php:error] [pid 4341] [client 40.xx.xxx.xxx:52355] PHP Fatal error: Uncaught mysqli_sql_exception: Conversion from collation utf8mb4_0900_ai_ci into latin1_swedish_ci impossible for parameter in /var/www/html/MyPHPfunction.php:8630\nStack trace:\n#0 /var/www/html/MyPHPfunction.php(8630): mysqli_stmt->execute()\n#1 /var/www/html/funct2.php(398): show_search_results()\n#2 {main}\n thrown in /var/www/html/funct2.php on line 8630
I could not find any table with latin1_swedish_ci
Does anyone know how this can be fixed? the full server is somehow useless at the moment :(