澳门新浦京娱乐场网站-www.146.net-新浦京娱乐场官网
做最好的网站

04_软件安装和卸载

澳门新浦京娱乐场网站,全部文字见 

Ubuntu

centos 服务器 mysql 安装,centosmysql

全部文字见 

 

CentOS 7的yum源中没有正常安装mysql时的mysql-sever文件,需要去官网上下载

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum localinstall mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server

提示 Is this ok [y/d/N] 时输入 y

然后开始联网下包更新。。

 

成功安装之后重启mysql服务

service mysqld restart

初次安装mysql是root账户是没有密码的

设置密码的方法

mysql -uroot
mysql> set password for ‘root’@‘localhost’ = password('mypasswd');
mysql> exit

  

服务器 mysql 安装,centosmysql 全部文字见 CentOS 7的yum源中没有正常安装mysql时的mysql-sever文件,需要...

要使用yum 安装mysql,要使用mysql的yum仓库,先从官网下载适合你系统的仓库

 

apt-get

  • 更新源服务器列表
sudo vi /etc/apt/sources.list
  • 04_软件安装和卸载。更新完服务器列表后需要更新下源
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 检查是否有损坏的依赖

http://dev.mysql.com/downloads/repo/yum/

CentOS 7的yum源中没有正常安装mysql时的mysql-sever文件,需要去官网上下载

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>

centos 6.7 对应的是mysql57-community-release-el6-7.noarch.rpm

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum localinstall mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server

原码安装

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还可以用来安装软件

然后安装一下这个仓库列表

提示 Is this ok [y/d/N] 时输入 y

CentOS

sudo rpm -Uvh mysql57-community-release-el6-7.noarch.rpm

然后开始联网下包更新。。

使用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]# 

上面提示表示安装成功
04_软件安装和卸载。注意:仔细看安装成功后的提示,然后来设置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密码

    澳门新浦京娱乐场网站 1

mysql登录成功

执行这个命令后就能看到可安装的mysql

 

yum repolist enabled | grep "mysql.*-community.*"

成功安装之后重启mysql服务

如果我们是要安装最新的版本,那么可以直接执行

service mysqld restart

sudo yum install mysql-server

初次安装mysql是root账户是没有密码的

安装完成后,使用 service 命令启动 mysql 服务:

设置密码的方法

service mysqld start

mysql -uroot
mysql> set password for ‘root’@‘localhost’ = password('mypasswd');
mysql> exit

查找mysql安装初始化密码

  

grep "password" /var/log/mysqld.log

2016-03-16T03:52:53.480966Z 1 [Note] A temporary password is generated for root@localhost: 8v&4wk(U5ilT ## 第一行“root@localhost:”后面的字符就是密码了,我们需要用它来设置我们自己的root登录密码

然后我们需要简单配置一下 mysql ,默认安装以后 mysql 的 root

用户是没有密码的,对于生产环境来说,这肯定是不行的,另外还有一些安全相关的设置,可以使用下面这行命令去配置一下,它是一个向导,问你一些问题,你要

给出答案,比如是否要设置 root 用户的密码, 密码是什么等等。

mysql_secure_installation

Enter current password for root (enter for none):

解释:输入当前 root 用户密码,默认为空,直接回车。

Set root password? [Y/n]  y

解释:要设置 root 密码吗?输入 y 表示愿意。

Remove anonymous users? [Y/n]  y

解释:要移除掉匿名用户吗?输入 y 表示愿意。

Disallow root login remotely? [Y/n]  y

解释:不想让 root 远程登陆吗?输入 y 表示愿意。

Remove test database and access to it? [Y/n]  y

解释:要去掉 test 数据库吗?输入 y 表示愿意。

Reload privilege tables now? [Y/n]  y

解释:想要重新加载权限吗?输入 y 表示愿意。

转移MySQL的数据文件到数据盘

更改MySQL目录

下面我整理一下把MySQL从/var/lib/mysql目录下面转移到/home/mysql_data/mysql目录的具体操作:

1、首先我们需要关闭MySQL,命令如下:

service mysqld stop

2、然后是转移数据,为了安全期间,我们采用复制命令cp,先找到mysql的原目录

cd /var/lib

ls

运行这个命令之后就会看到mysql的目录了,然后执行cp命令

cp -a mysql /mnt/web/data/ #这样就把数据库复制到/mnt/web/data/mysql/下面去了

注意:(-a这个参数一定要带着,否则复制过去的权限就不对了。)

如果数据库比较大的话,时间会比较长,可能会超时,具体怎么设置ssh不超时的办法,请大家自己找相关资料。

3、然后我们修改配置文件,一共有三个,下面我一一说明:

修改第一个文件:修改之前先备份cp /etc/my.cnf /etc/my.cnf.back

vi /etc/my.cnf

打开之后修改datadir的目录为/mnt/web/data/mysql

把socket改成/mnt/web/data/mysql/mysql.sock #为了安全起见,你可以把原来的注释掉,然后重新加入一行,改成现在的目录。

==================================================================================

修改第二个文件:修改之前先备份 cp /etc/init.d/mysqld /etc/init.d/mysqld.back

vi /etc/init.d/mysqld

注意:准确的位置是/etc/rc.d/init.d/mysqld,由于这里这里有一个/etc/init.d到/etc/rc.d/init.d的映射,

所以用上面的命令即可,也简单。

把其中get_mysql_option mysqld datadir "/var/lib/mysql"一行中,等号右边的路径改成你现在的实际存放路径:/mnt/web/data/mysql

=================================================================================

修改第三个文件:修改之前先备份 cp /usr/bin/mysqld_safe /usr/bin/mysqld_safebak

vi /usr/bin/mysqld_safe

这里也是修改 DATADIR=/var/lib/mysql的目录为/mnt/web/data/mysql

==================================================================================

4、下面需要建立一个mysql.sock的链接:

ln -s /mnt/web/data/mysql/mysql.sock /var/lib/mysql/mysql.sock

至此所有的修改都完成了,下面启动mysql

service mysqld start

或者重启linux

reboot

如果能正常启动,说明修改成功。

本文由澳门新浦京娱乐场网站发布于数据库,转载请注明出处:04_软件安装和卸载