当前位置: 首页 > article >正文

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


http://www.kler.cn/a/291071.html

相关文章:

  • maven-resources-production:ratel-fast: java.lang.IndexOutOfBoundsException
  • 详解 Qt WebEngine 模块
  • Git实用指南(精简版)
  • Map.put 方法
  • 【HarmonyOS NEXT】Web 组件的基础用法以及 H5 侧与原生侧的双向数据通讯
  • Python国内10个镜像源-地址汇总以及测评
  • 关于vue中v-model绑定radio表单元素的说明
  • 开源 AI 智能名片小程序在内容营销中的应用与价值
  • Golang 教程7——切片、映射
  • 掌握TensorFlow:构建您的第一个机器学习模型
  • 算法基础-快速排序
  • JPA关联mybatis
  • GAMES104:10+11游戏引擎中物理系统的基础理论算法和高级应用-学习笔记
  • 流量密码算被你玩明白了!用AI做萌宠+萌娃短视频,百万播放量
  • union_collinear_contours_xld 算子介绍一下,条件关系
  • 【c++】平常自己练习写代码的两个大方向
  • Golang | Leetcode Golang题解之第387题字符串中的第一个唯一字符
  • 计算机毕业设计hadoop+spark+hive知识图谱股票推荐系统 股票数据分析可视化大屏 股票基金爬虫 股票基金大数据 机器学习 大数据毕业设计
  • 【大数据分析与挖掘算法】matlab实现——改进的Apriori关联规则算法
  • 基于单片机的浴室防雾镜系统设计
  • 使用python+opencv解析图像和文本数据
  • 前端常用的几种设计模式--观察者模式、单例模式等
  • 前端:HTML、CSS、JS、Vue
  • 怎样在公司将手机屏幕(远程)投屏到家里的大电视上?
  • Redis在Spring Boot中的应用详细讲解和案例示范
  • Verilog刷题笔记62