linux下安装mysql5.5.16

来源:互联网 发布:犀牛地方门户源码官网 编辑:程序博客网 时间:2024/06/05 16:35

1.环境描述

安装时用的Linux为rhel6.3 x86_64,用的mysql为mysql5.5.16 x86_64,下载地址:www.oracle.com
安装方式为rpm二进制安装,所需要的两个mysql rpm安装包为:
MySQL-server-5.5.16-1.rhel5.x86_64.rpm
MySQL-client-5.5.16-1.rhel5.x86_64.rpm
关于这两个包的作用和关系自己百度吧,这里不再赘述。
利用rpm二进制安装方式来安装mysql过程非常简单,rpm命令在安装时常用的参数是-hiv,其中i表示将安装指定的rmp软件包,v表示输出安装时的详细信息,h表示在安装期间出现“#”号来显示目前的安装进度。

2.检查并卸载已经存在的mysql

2.1.检查

[root@zabbix ~]# rpm -qa|grep mysqlmysql-libs-5.1.61-4.el6.x86_64[root@zabbix ~]# 

2.2.卸载

[root@zabbix ~]# rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64[root@zabbix ~]# 

如果系统上存在mysql,在安装前没卸载,则安装时会报如下错误:

[root@zabbix ~]# rpm -hiv MySQL-server-5.5.16-1.rhel5.x86_64.rpmPreparing...                ########################################### [100%]        file /usr/share/mysql/charsets/README from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64        file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.5.16-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64[root@zabbix ~]# 

3.安装mysql server和client

3.1.安装server

[root@zabbix ~]# rpm -hiv MySQL-server-5.5.16-1.rhel5.x86_64.rpmPreparing...                ########################################### [100%]   1:MySQL-server           ########################################### [100%]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 zabbix password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default.  This isstrongly recommended for production servers.See the manual for more instructions.Please report any problems with the /usr/bin/mysqlbug script![root@zabbix ~]# 

3.2.安装mysql client

[root@zabbix ~]# rpm -hiv MySQL-client-5.5.16-1.rhel5.x86_64.rpm Preparing...                ########################################### [100%]   1:MySQL-client           ########################################### [100%][root@zabbix ~]# 

4.拷贝并修改配置文件

[root@zabbix ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

修改字符集:

[root@zabbix ~]# vi /etc/my.cnf

如果mysql版本为5.5或5.6则在[mysqld]下添加如下两行:

character-set-server=utf8collation-server=utf8_general_ci

如果mysql是其他版本则在[mysqld]下添加如下一行:

default-character-set=utf8

在[client]下添加一行

default-character-set=utf8

5.打开数据库

[root@zabbix ~]# service mysql start
Starting MySQL..[确定]
[root@zabbix ~]#

6.修改root密码

[root@zabbix ~]# mysqladmin -uroot password root

7.登录mysql

[root@zabbix ~]# mysql -uroot -prootWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.5.16-log MySQL Community Server (GPL)Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || test               |+--------------------+4 rows in set (0.00 sec)mysql> 

注:为了使博客更加完善,便于更好的分享,请读者为文章中的错误进行指正,博主会定期更正,谢谢!

Keep fighting.
Warrior
2016.4.26
– The End –

1 0
原创粉丝点击