ubuntu16.04离线安装MySQL8.0.25过程、体会、教程

ubuntu16.04离线安装MySQL8.0.25

1、版本问题

ubuntu16.04离线安装MySQL8.0.25过程、体会、教程_第1张图片

2、找到对应版本

ubuntu16.04离线安装MySQL8.0.25过程、体会、教程_第2张图片

3、下载版本并上传到虚拟机

ubuntu16.04离线安装MySQL8.0.25过程、体会、教程_第3张图片

4、新建目录并mv到该目录

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# 
​

5、解压该文件

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# 
​

6、有顺序的安装

6.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

6.2要求输入root密码

ubuntu16.04离线安装MySQL8.0.25过程、体会、教程_第4张图片

6.3、报错处理,已经存在5.7版本的相关安装

ubuntu16.04离线安装MySQL8.0.25过程、体会、教程_第5张图片

6.4、到官网下载相应的文件:

ubuntu16.04离线安装MySQL8.0.25过程、体会、教程_第6张图片

6.5、卸载mysql5.7版本

彻底卸载宝典, 拿走不谢(一定要提前备份好数据,造成数据丢失,概不负责,仅限技术交流)

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.重新执行安装脚本

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口令

ubuntu16.04离线安装MySQL8.0.25过程、体会、教程_第7张图片

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> 
​

修改远程链接的问题

1、查看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
​

2.将host改为%

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> 

3.刷新权限

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> 

4、更改连接的密码校验方式

caching_sha2_password`加密方式在远程访问时候不支持。
需要改成:`mysql_native_password

5.更改连接方式

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> 

6.刷新权限

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> 

你可能感兴趣的:(ubuntu,服务器,linux)