美文网首页Linux
04_软件安装和卸载(Ubuntu)

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

作者: 对方不想理你并向你抛出一个异常 | 来源:发表于2017-08-04 22:31 被阅读12次

    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登录成功

    相关文章

      网友评论

        本文标题:04_软件安装和卸载(Ubuntu)

        本文链接:https://www.haomeiwen.com/subject/sbgblxtx.html