1.卸载
首先在终端中查看MySQL的依赖项:
dpkg --list|grep mysql
卸载:
sudo apt-get remove mysql-common
卸载:
sudo apt-get autoremove --purge mysql-server-5.7
清除残留数据:
dpkg -l|grep ^rc|awk '{print$2}'|sudo xargs dpkg -P
再次查看MySQL的剩余依赖项:
dpkg --list|grep mysql
继续删除剩余依赖项
sudo apt-get autoremove --purge mysql-apt-config
other way卸载mysql
自动卸载mysql相关的软件
sudo apt-get autoremove --purge mysql
删除掉卸载不完全留下的文件目录
sudo rm -rf /etc/mysql /var/lib/mysql
自动卸载无用的程序
sudo apt-get autoremove
自动清理卸载后的残留信息
sudo apt-get autoclean
2.安装
mysql 8.0配置
apt install mysql-server-8.0 mysql-client-8.0
sudo apt-get install libmysql++-dev #mysql.h头文件配置
sudo cat /etc/mysql/debian.cnf
#mysql -u用户名 -p密码 #进去mysql
use mysql #使用mysql数据库
select host, user, authentication_string from user;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
#将 MySQL 数据库中的 'root'@'localhost' 用户的身份验证方式修改为 mysql_native_password,并将密码设置为 'root'
flush privileges;
sudo mysql_secure_installation
3.其他
eg.打包目录server
tar -czf ser.tar.gz server
-c 指定目录
-z 支持gzip解压文件
-f 指定压缩文件
远程连接mysql
create user root@'%' identified by '123456';
grant all privileges on *.* to root@'%' with grant option;
FLUSH PRIVILEGES;
use mysql;
select user,host from user;
update user set host = '%' where user = 'root';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
FLUSH PRIVILEGES;
cd /etc/mysql/mysql.conf.d/
sudo vim mysqld.cnf`
将其中的bind-address改为0.0.0.0:
sudo systemctl restart mysql