1.下载全量安装包并解压

cd /usr/local/src
wget --no-check-certificate https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-server_5.7.36-1debian10_amd64.deb-bundle.tar
tar -vxf mysql-server_5.7.36-1debian10_amd64.deb-bundle.tar

2.更新系统安装依赖

apt-get update
apt-get upgrade
apt-get install -y libnuma1 libaio1 libmecab2 psmisc

3.预设置密码

提前删除 dev test source 用不到

dpkg-preconfigure mysql-community-server_5.7.36-1debian7_amd64.deb

4.继续进行安装

dpkg -i libmysqlclient20_5.7.36-1debian7_amd64.deb
dpkg -i libmysqlclient-dev_5.7.36-1debian7_amd64.deb
dpkg -i mysql-community-client_5.7.36-1debian7_amd64.deb
dpkg -i mysql-client_5.7.36-1debian7_amd64.deb
dpkg -i mysql-common_5.7.36-1debian7_amd64.deb
dpkg -i mysql-community-server_5.7.36-1debian7_amd64.deb
dpkg -i mysql-server_5.7.36-1debian7_amd64.deb

如果仍提示缺少依赖执行apt-get install -f即可

5.远程登录

mysql -u root -p #登录数据库
use mysql; #进入数据库
update user set host='%' where user='root'; #设置主机
exit; #退出数据库
vim /etc/mysql/mysql.conf.d/mysqld.cnf #编辑配置文件
#注释如下一行
# bind-address = 127.0.0.1

6.配置调优

vim /etc/mysql/mysql.conf.d/mysqld.cnf #编辑配置文件
#索引缓存,根据内存大小而定,如果是独立的db服务器,可以设置高达80%的内存总量
key_buffer_size = 4G
#连接排队列表总数
back_log = 200
max_allowed_packet = 128M
#打开表缓存总数,可以避免频繁的打开数据表产生的开销
table_definition_cache = 512
#每个线程排序所需的缓冲
sort_buffer_size = 64M
#每个线程读取索引所需的缓冲
read_buffer_size = 64M
#MyISAM表发生变化时重新排序所需的缓冲
myisam_sort_buffer_size = 128M
#缓存可重用的线程数
thread_cache_size = 128
#查询结果缓存
query_cache_size = 1G
#设置超时时间,能避免长连接
wait_timeout = 60

7.重启服务

service mysql restart

8.卸载

apt-get --purge remove mysql-*
apt-get autoremove
apt-get autoclean
rm /etc/mysql/ -rf
rm /var/lib/mysql/ -rf

参考文章:

https://www.wpon.cn/6935.html

https://www.cnblogs.com/itfky/p/13732841.html

Q.E.D.