ubuntu环境快速安装mysql

1、环境准备

       因为默认安装的源的地址都是国外地址,有时是被防火墙拦截,有时是速度太慢,有时是有些安装包在上面根本就找不到,所以需要替换成国内的源。

1.1先将之前的源列表文件备份

先备份sources.list文件,执行命令:cp  /etc/apt/sources.list   /etc/apt/sources.list-bak回车

1.2、修改sources.list文件
    该文件路径为:/etc/apt/sources.list,此文件的内容和系统版本有关,下面的内容适用于ubuntu16.04系统,使用下面的内容替换该文件的原有内容。

deb http://mirrors.aliyun.com/ubuntu/ xenial main multiverse restricted universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main multiverse restricted universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main multiverse restricted universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main multiverse restricted universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main multiverse restricted universe

deb-src http://mirrors.aliyun.com/ubuntu/xenial main multiverse restricted universe

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main multiverse restricted universe

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main multiverse restricted universe

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main multiverse restricted universe

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main multiverse restricted universe

1.3、执行更新命令
apt-get   update

2、下载安装包

wget --no-check-certificate https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-server_5.7.29-1ubuntu16.04_amd64.deb-bundle.tar

3、解压安装包 

tar -xvf mysql-server_5.7.29-1ubuntu16.04_amd64.deb-bundle.tar -C mysql
mysql-common_5.7.29-1ubuntu16.04_amd64.deb
libmysqld-dev_5.7.29-1ubuntu16.04_amd64.deb
mysql-testsuite_5.7.29-1ubuntu16.04_amd64.deb
mysql-community-source_5.7.29-1ubuntu16.04_amd64.deb
mysql-server_5.7.29-1ubuntu16.04_amd64.deb
libmysqlclient-dev_5.7.29-1ubuntu16.04_amd64.deb
mysql-client_5.7.29-1ubuntu16.04_amd64.deb
mysql-community-test_5.7.29-1ubuntu16.04_amd64.deb
libmysqlclient20_5.7.29-1ubuntu16.04_amd64.deb
mysql-community-server_5.7.29-1ubuntu16.04_amd64.deb
mysql-community-client_5.7.29-1ubuntu16.04_amd64.deb

4、升级并安装一些依赖项 

apt-get -f upgrade

5、安装一系列mysql包 

dpkg -i mysql-common_5.7.29-1ubuntu16.04_amd64.deb
dpkg -i libmysqlclient20_5.7.29-1ubuntu16.04_amd64.deb
dpkg -i libmysqlclient-dev_5.7.29-1ubuntu16.04_amd64.deb
dpkg -i libmysqld-dev_5.7.29-1ubuntu16.04_amd64.deb
dpkg -i mysql-community-client_5.7.29-1ubuntu16.04_amd64.deb
dpkg -i mysql-client_5.7.29-1ubuntu16.04_amd64.deb
dpkg -i mysql-community-source_5.7.29-1ubuntu16.04_amd64.deb

dpkg -i mysql-community-server_5.7.29-1ubuntu16.04_amd64.deb

如果报错:
Unpacking mysql-community-server (5.7.29-1ubuntu16.04) over (5.7.29-1ubuntu16.04) ...
dpkg: dependency problems prevent configuration of mysql-community-server:
 mysql-community-server depends on libmecab2 (>= 0.996-1.2ubuntu1); however:
  Package libmecab2 is not installed.

解决方法:
sudo apt-get -f install

dpkg -i mysql-community-server_5.7.29-1ubuntu16.04_amd64.deb 
(Reading database ... 275172 files and directories currently installed.)
Preparing to unpack mysql-community-server_5.7.29-1ubuntu16.04_amd64.deb ...
.
Unpacking mysql-community-server (5.7.29-1ubuntu16.04) over (5.7.29-1ubuntu16.04) ...
dpkg: dependency problems prevent configuration of mysql-community-server:
 mysql-community-server depends on libmecab2 (>= 0.996-1.2ubuntu1); however:
  Package libmecab2 is not installed.
  
解决方法:
apt-get -f upgrade

6、查看版本 

root@ubuntu:/home/mysql#mysql -V
mysql  Ver 14.14 Distrib 5.7.29, for Linux (x86_64) using  EditLine wrapper

7、验证安装是否可以正常使用

root@ubuntu:/home/mysql#mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.29 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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

  • 15
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编码小哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值