在使用apt-get install XXX,报E: Unable to locate package XXX

一、在使用apt-get install XXX安装某个软件的时候,经常会出现一个错
例如以mysql为例:

root@iZ2zeht3zvxbq5ycy698pwZ:~# apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mysql-server

二、一般这样的问题,多出现于只需要升级一下安装源就好了

root@iZ2zeht3zvxbq5ycy698pwZ:~# apt-get update
Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu xenial InRelease [247 kB]
Get:2 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-updates InRelease [102 kB]
Get:3 http://mirrors.cloud.aliyuncs.com/ubuntu xenial-security InRelease [102 kB]
Get:4 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main Sources [868 kB]
Get:5 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/universe Sources [7728 kB]
Get:6 http://mirrors.cloud.aliyuncs.com/ubuntu xenial/main amd64 Packages [1201 kB]

三、再安装就好了,不会再报错了

root@iZ2zeht3zvxbq5ycy698pwZ:~# apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.0-5
  libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
  libhttp-date-perl libhttp-message-perl libio-html-perl
  liblwp-mediatypes-perl liburi-perl mysql-client-5.7 mysql-client-core-5.7
  mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
  libdata-dump-perl libipc-sharedcache-perl libwww-perl tinyca
The following NEW packages will be installed:

四、解决啦

点赞