Ubuntu 上 MySQL 兼容性问题的系统化处理
一 版本匹配与安装路径
二 字符集与中文乱码
[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4
sudo systemctl restart mysql
mysql -e "SHOW VARIABLES LIKE '%character%';"
mysql -e "SHOW VARIABLES LIKE '%collation%';"
三 认证插件与旧应用兼容
default_authentication_plugin=mysql_native_password
重启后新建用户将默认使用该插件;已有用户需单独修改。ALTER USER 'app'@'host' IDENTIFIED WITH mysql_native_password BY 'StrongPass!';
FLUSH PRIVILEGES;
四 网络与连接方式
[mysqld]
bind-address = 127.0.0.1
[mysqld]
bind-address = ::
sudo systemctl restart mysql
ss -ltnp | grep 3306
五 工具链与运维兼容
mysql --version
mysqladmin version
sudo mysqladmin -u root -p status
sudo apt install php-mbstring php-zip php-gd php-json php-curl
tail -n50 /var/log/mysql/error.log