ubuntu离线安装mysql
https://dev.mysql.com/downloads/mysql/
下载离线包
tar -xvf mysql-server_8.4.3-1ubuntu24.04_amd64.deb-bundle.tar -C /mysql
解压完依次执行:
dpkg -i mysql-community-client-plugins_8.4.3-1ubuntu24.04_amd64.deb dpkg -i mysql-community-client-core_8.4.3-1ubuntu24.04_amd64.deb dpkg -i mysql-common_8.4.3-1ubuntu24.04_amd64.deb dpkg -i mysql-community-client_8.4.3-1ubuntu24.04_amd64.deb dpkg -i mysql-client_8.4.3-1ubuntu24.04_amd64.deb dpkg -i libmysqlclient24_8.4.3-1ubuntu24.04_amd64.deb dpkg -i libmysqlclient-dev_8.4.3-1ubuntu24.04_amd64.deb dpkg -i mysql-community-server-core_8.4.3-1ubuntu24.04_amd64.deb dpkg -i mysql-community-server_8.4.3-1ubuntu24.04_amd64.deb dpkg -i mysql-server_8.4.3-1ubuntu24.04_amd64.deb
如遇失败:sudo apt-get remove --purge ...
mysql server安装过程中会提示输入root用户密码,待所有安装完成后,使用命令登陆即可。如密码设置为123456
查看启动状态
sudo systemctl start mysql
设置MySQL开机启动:
sudo systemctl enable mysql
默认都是localhost,把root调整为远程登录用户
use mysql;
update user set host = '%' where user = 'root';
刷新
FLUSH PRIVILEGES;
优化Mysql配置
mysql> set global max_connections=3000 ##最大连接数
mysql> set global thread_cache_size=60; ##最大并发数