root@ubuntu:/home/hua# mv mysql-server_8.0.25-1ubuntu16.04_amd64.deb-bundle.tar /home/mysql root@ubuntu:/home/hua# cd /home/mysql root@ubuntu:/home/mysql# ls mysql-community-client-plugins_8.0.25-1ubuntu16.04_amd64.deb mysql-server_8.0.25-1ubuntu16.04_amd64.deb-bundle.tar root@ubuntu:/home/mysql#
root@ubuntu:/home/mysql# clear root@ubuntu:/home/mysql# tar -xvf mysql-server_8.0.25-1ubuntu16.04_amd64.deb-bundle.tar libmysqlclient21_8.0.25-1ubuntu16.04_amd64.deb libmysqlclient-dev_8.0.25-1ubuntu16.04_amd64.deb mysql-client_8.0.25-1ubuntu16.04_amd64.deb mysql-common_8.0.25-1ubuntu16.04_amd64.deb mysql-community-client_8.0.25-1ubuntu16.04_amd64.deb mysql-community-client-core_8.0.25-1ubuntu16.04_amd64.deb mysql-community-client-plugins_8.0.25-1ubuntu16.04_amd64.deb mysql-community-server_8.0.25-1ubuntu16.04_amd64.deb mysql-community-server-core_8.0.25-1ubuntu16.04_amd64.deb mysql-community-server-debug_8.0.25-1ubuntu16.04_amd64.deb mysql-community-test_8.0.25-1ubuntu16.04_amd64.deb mysql-community-test-debug_8.0.25-1ubuntu16.04_amd64.deb mysql-server_8.0.25-1ubuntu16.04_amd64.deb mysql-testsuite_8.0.25-1ubuntu16.04_amd64.deb root@ubuntu:/home/mysql#
dpkg -i mysql-common_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-client-plugins_8.0.25-1ubuntu16.04_amd64.deb && dpkg-preconfigure mysql-community-server_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-client-plugins_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i libmysqlclient21_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i libmysqlclient-dev_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-client-core_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-client_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-client_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-server-core_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-server_8.0.25-1ubuntu16.04_amd64.deb
彻底卸载宝典, 拿走不谢(一定要提前备份好数据,造成数据丢失,概不负责,仅限技术交流)
5.1、首先用以下命令查看自己的mysql有哪些依赖包
dpkg --list | grep mysql
5.2、先依次执行以下命令
sudo apt-get remove mysql-common
sudo apt-get autoremove --purge mysql-server-5.0 # 卸载 MySQL 5.x 使用, 非5.x版本可跳过该步骤
sudo apt-get autoremove --purge mysql-server
sudo rm -rf /etc/mysql/ /var/lib/mysql #很重要
5.3、然后再用 dpkg --list | grep mysql 查看一下依赖包
5.4、最后用下面命令清除残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
5.5、查看从MySQL APT安装的软件列表, 执行后没有显示列表, 证明MySQL服务已完全卸载
dpkg -l | grep mysql | grep i
7.1 安装脚本
dpkg -i mysql-common_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-client-plugins_8.0.25-1ubuntu16.04_amd64.deb && dpkg-preconfigure mysql-community-server_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-client-plugins_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i libmysqlclient21_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i libmysqlclient-dev_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-client-core_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-client_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-client_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-server-core_8.0.25-1ubuntu16.04_amd64.deb && dpkg -i mysql-community-server_8.0.25-1ubuntu16.04_amd64.deb
7.2设置root口令
7.3、设置编码,启动测试
echo "character-set-server=utf8" >> /etc/mysql/mysql.conf.d/mysqld.cnf service mysql restart
7.4 启动测试
root@ubuntu:/home/mysql# service mysql start root@ubuntu:/home/mysql# mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.25 MySQL Community Server - GPL Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.25 | +-----------+ 1 row in set (0.00 sec) mysql>
mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select host,user,plugin from user; +-----------+------------------+-----------------------+ | host | user | plugin | +-----------+------------------+-----------------------+ | localhost | mysql.infoschema | caching_sha2_password | | localhost | mysql.session | caching_sha2_password | | localhost | mysql.sys | caching_sha2_password | | localhost | root | caching_sha2_password | +-----------+------------------+-----------------------+ 4 rows in set (0.00 sec) mysql> ^C
mysql> update user set host='%' where user='root'; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select host,user,plugin from user; +-----------+------------------+-----------------------+ | host | user | plugin | +-----------+------------------+-----------------------+ | % | root | caching_sha2_password | | localhost | mysql.infoschema | caching_sha2_password | | localhost | mysql.session | caching_sha2_password | | localhost | mysql.sys | caching_sha2_password | +-----------+------------------+-----------------------+ 4 rows in set (0.00 sec) mysql>
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql>
caching_sha2_password`加密方式在远程访问时候不支持。 需要改成:`mysql_native_password
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; Query OK, 0 rows affected (0.01 sec) mysql>
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql>