Ubuntu 离线安装 Mysql5.7
记录一下在 Ubuntu 22.04 上安装 Mysql 5.7.42 的过程.
1. 下载安装包
从官网下载安装包: https://downloads.mysql.com/archives/community/
下载这个文件
然后解压
tar -xvf ./mysql-server_5.7.42-1ubuntu18.04_amd64.deb-bundle.tar
# 这边一般直接tab补全就可以了
2. 开始安装
# 1. 安装 mysql-common
sudo dpkg -i mysql-common_5.7.42-1ubuntu18.04_amd64.deb
# 2. 安装 mysql-community-client
sudo dpkg -i mysql-community-client_5.7.42-1ubuntu18.04_amd64.deb
# 这里报错提示要安装 libaio1 和 libtinfo5
# 先安装别的
# 3. 安装 libmysqlclient20 ...
sudo dpkg -i libmysqlclient20_5.7.42-1ubuntu18.04_amd64.deb
# 4. 安装 libmysqlclient-dev ...
sudo dpkg -i libmysqlclient-dev_5.7.42-1ubuntu18.04_amd64.deb
# 5. 安装 libmysqld-dev ...
sudo dpkg -i libmysqld-dev_5.7.42-1ubuntu18.04_amd64.deb
# 6. 解决libtinfo5 依赖的问题
进入 https://pkgs.org/ 网站进行搜索
选择适合自己系统的版本点进去,找到 Dowanload
复制链接
wget http://archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2_amd64.deb
libaio1 同理
wget http://archive.ubuntu.com/ubuntu/pool/main/liba/libaio/libaio1_0.3.112-13build1_amd64.deb
安装
# 1. 解决 libtinfo5 和 libaio1 依赖的问题
sudo dpkg -i libtinfo5_6.3-2_amd64.deb
sudo dpkg -i libaio1_0.3.112-13build1_amd64.deb
# 2. 安装 mysql-community-client
sudo dpkg -i mysql-community-client_5.7.42-1ubuntu18.04_amd64.deb
# 3. 安装 mysql-client
sudo dpkg -i mysql-client_5.7.42-1ubuntu18.04_amd64.deb
# 4. 安装 mysql-community-source
sudo dpkg -i mysql-community-source_5.7.42-1ubuntu18.04_amd64.deb
# 5. 安装 mysql-community-server
sudo dpkg -i mysql-community-server_5.7.42-1ubuntu18.04_amd64.deb
# 发现需要 libmecab2 依赖
# 同之前的解决方式
wget http://archive.ubuntu.com/ubuntu/pool/main/m/mecab/libmecab2_0.996-14build9_amd64.deb
sudo dpkg -i libmecab2_0.996-14build9_amd64.deb
# 6. 再次安装 mysql-community-server
sudo dpkg -i mysql-community-server_5.7.42-1ubuntu18.04_amd64.deb
# 这里提示设置mysql root密码,设置一下就好
# 7. 安装 mysql-server
sudo dpkg -i mysql-server_5.7.42-1ubuntu18.04_amd64.deb
3. 测试
# 检查状态
systemctl status mysql
我到这里显示 Active: active (running)
, 说明安装成功了, 进行登录测试
mysql -u root -p
如哦显示 Welcome to the MySQL monitor. Commands end with ; or \g.
说明登录成功了.
4. 其他
如果需要运行 MySQL 能够远程登录
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
# 修改配置
# 注释掉 bind-address = 127.0.0.1
# 然后重启 MySQL 服务即可
sudo systemctl restart mysql