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

ubuntu16.04离线安装MySQL8.0.25

1、版本问题

2、找到对应版本

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密码

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

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

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

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> 

  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值