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

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.mrgr.cn/news/17248.html

相关文章:

  • 浅析Java线程池实现原理
  • Java注解和JDK新特性
  • Python爬虫案例四:爬取某个博主的所有文章保存成PDF格式
  • C++11 可变参数模板
  • 两个月冲刺软考——求解关系模式达到了第几范式题型(例题+讲解,一看就会)
  • Linux 进程概念
  • 集成电路学习:什么是GUI图形用户界面
  • 服务器间进行文件传输-SFTPSCP一篇搞定
  • DateTime与时间戳转换
  • 计算机毕业设计推荐-基于python的公司员工考勤管理系统
  • Python编程基础知识,让编程基础更加扎实(输出个人简介)
  • 【解决】CentOS7 生命周期结束后 使用 yum命令报错问题
  • 【面试经验】京东-数据产品面经(一面)
  • 【深海王国】初中生也能玩的建模与3D打印?SolidWorks带你走进3D打印的神奇之旅(1.5)
  • 驱动(RK3588S)第四课时:模块化编程
  • Java-数据结构-ArrayList-练习 ψ(*`ー´)ψ
  • C++系列-STL容器之list
  • 4-8 进入C语言,并跳转到loarder(1)
  • 手把手带你实现C语言扫雷进阶(1)(接上回基础版扫雷,附上源码)
  • 第十七篇——九变篇:紧扣战略重心,别跑题