04_软件安装和卸载(Ubuntu)

Ubuntu

apt-get

  • 更新源服务器列表
sudo vi /etc/apt/sources.list
  • 更新完服务器列表后需要更新下源
sudo apt-get update 更新源
sudo apt-get install package 安装包
sudo apt-get remove package 删除包
sudo apt-cache search package 搜索软件包
sudo apt-cache show package 获取包的相关信息,如说明、大小、版本等
sudo apt-get install package --reinstall 重新安装包
sudo apt-get -f install 修复安装
sudo apt-get remove package --purge 删除包,包括配置文件等
sudo apt-get build-dep package 安装相关的编译环境
sudo apt-get upgrade 更新已安装的包
sudo apt-get dist-upgrade 升级系统
sudo apt-cache depends package 了解使用该包依赖那些包
sudo apt-cache rdepends package 查看该包被哪些包依赖
sudo apt-get source package 下载该包的源代码
sudo apt-get clean && sudo apt-get autoclean 清理无用的包
sudo apt-get check 检查是否有损坏的依赖

deb包安装

安装deb软件包命令: sudo dpkg -i xxx.deb
删除软件包命令: sudo dpkg -r xxx.deb
连同配置文件一起删除命令: sudo dpkg -r --purge xxx.deb
查看软件包信息命令: sudo dpkg -info xxx.deb
查看文件拷贝详情命令: sudo dpkg -L xxx.deb
查看系统中已安装软件包信息命令: sudo dpkg -l
重新配置软件包命令: sudo dpkg-reconfigure xxx
  • 浏览已安装的程序
dpkg --list
  • 卸载程序和所有配置文件
sudo apt-get --purge remove <programname>
  • 只卸载程序
sudo apt-get remove <programname>

原码安装

1. 解压缩源代码包
2. cd dir
3. ./configure
检测文件是否缺失,创建Makefile,检测编译环境
4. make
编译源码,生成库和可执行程序
5. sudo make install
把库和可执行程序,安装到系统路径下
6. sudo make distclean
删除和卸载软件 

注意:

sudo aptitude show softname
  1. 查看软件信息,是否安装、软件大小等等信息
  2. 该命令首次使用时需要安装:sudo apt-get install aptitude
sudo aptitude install softname
  1. aptitude还可以用来安装软件

CentOS

使用RPM包安装mysql

安装环境:Centos6.7桌面版

  • 下载
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-server-5.5.48-1.el6.x86_64.rpm
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-client-5.5.48-1.el6.x86_64.rpm
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-devel-5.5.48-1.el6.x86_64.rpm
  • 安装依赖
    rpm -ivh MySQL-devel-5.5.48-1.el6.x86_64.rpm
[root@huachao mysql]# rpm -ivh MySQL-devel-5.5.48-1.el6.x86_64.rpm 
warning: MySQL-devel-5.5.48-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]
  • 安装mysql-service
    rpm -ivh MySQL-server-5.5.48-1.el6.x86_64.rpm
[root@huachao mysql]# rpm -ivh MySQL-server-5.5.48-1.el6.x86_64.rpm 
warning: MySQL-server-5.5.48-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
    file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
    file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.5.48-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64
  • 卸载冲突的包mysql-libs-5.1.73-5.el6_6.x86_64
    rpm -e mysql-libs-5.1.73-5.el6_6.x86_64 --nodeps
    没有提示表示卸载成功

  • 再安装mysql-service
    rpm -ivh MySQL-server-5.5.48-1.el6.x86_64.rpm

[root@huachao mysql]# rpm -ivh MySQL-server-5.5.48-1.el6.x86_64.rpm 
warning: MySQL-server-5.5.48-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
170808  4:34:10 [Note] /usr/sbin/mysqld (mysqld 5.5.48) starting as process 4144 ...
170808  4:34:10 [Note] /usr/sbin/mysqld (mysqld 5.5.48) starting as process 4151 ...

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h huachao.com password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

[root@huachao mysql]# 

上面提示表示安装成功
注意:仔细看安装成功后的提示,然后来设置mysql,不然这个安装的mysql就费了,重新安装的话会更难装

  • 查看端口
    netstat -ntpl
[root@huachao mysql]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:40290               0.0.0.0:*                   LISTEN      2248/rpc.statd      
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      2191/rpcbind        
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2487/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      2292/cupsd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      2679/master         
tcp        0      0 :::46790                    :::*                        LISTEN      2248/rpc.statd      
tcp        0      0 :::111                      :::*                        LISTEN      2191/rpcbind        
tcp        0      0 :::22                       :::*                        LISTEN      2487/sshd           
tcp        0      0 ::1:631                     :::*                        LISTEN      2292/cupsd          
tcp        0      0 ::1:25                      :::*                        LISTEN      2679/master 

没有3306的端口,说明mysql的service没有启动,接下来启动mysql的service

  • 启动mysql
    service mysql start
[root@huachao mysql]# service mysql start
Starting MySQL..[确定]
[root@huachao mysql]# 

启动成功后可以再查看一次端口,可以看到3306的端口

  • 安装mysql-client才能设置mysql
[root@huachao mysql]# rpm -ivh MySQL-client-5.5.48-1.el6.x86_64.rpm 
warning: MySQL-client-5.5.48-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]

安装成功

  • 设置mysql密码
    /usr/bin/mysql_secure_installation
    按回车键后会有5个需要确认的地方
    • Enter current password for root (enter for none):
      输入当前密码,当前没有密码,直接按回车键
    • Set root password? [Y/n] y
      设置root密码,按y然后按回车
      New password:输入root密码,然后按回车
    • Remove anonymous users? [Y/n] y
      删除匿名用户,按y然后按回车
    • Disallow root login remotely? [Y/n] n
      不允许远程登录,按n然后按回车
    • Remove test database and access to it? [Y/n] y
      删除测试数据库,按y然后按回车
    • Reload privilege tables now? [Y/n] y
      重新加载权限表,按y然后按回车

mysql就按安装和配置成功了

  • 登录mysql
    mysql -uroot -p密码

    mysql登录成功
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,294评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,493评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,790评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,595评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,718评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,906评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,053评论 3 410
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,797评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,250评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,570评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,711评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,388评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,018评论 3 316
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,796评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,023评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,461评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,595评论 2 350

推荐阅读更多精彩内容