MySQL5.5.25如何使用rpm安装及升级到5.6.26forRedHatEnterpriseLinux6.4

小编给大家分享一下MySQL 5.5.25如何使用rpm安装及升级到5.6.26 for RedHat Enterprise Linux 6.4,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

目前创新互联已为上1000家的企业提供了网站建设、域名、虚拟主机网站运营、企业网站设计、禹会网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

环境:RedHat Enterprise Linux 6.4(x86_64)  MySQL:5.6.25  
        
RPM包安装方法:
 
步骤一:准备工作:
 
1、建议删除系统存在的mysql用户
[root@mysql01 Desktop]# id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql)
[root@mysql01 Desktop]# userdel -r mysql
 
2、清理已安装的mysql程序包
[root@mysql01 Desktop]# service mysql status
[root@mysql01 Desktop]# service mysql stop
[root@mysql01 Desktop]# service mysql status
[root@suzzy ~]# rpm -qa|grep mysql
mysql-server-5.1.66-2.el6_3.x86_64
dovecot-mysql-2.0.9-5.el6.x86_64
qt-mysql-4.6.2-25.el6.x86_64
rsyslog-mysql-5.8.10-6.el6.x86_64
mysql-5.1.66-2.el6_3.x86_64
mod_auth_mysql-3.0.0-11.el6_0.1.x86_64
mysql-devel-5.1.66-2.el6_3.x86_64
mysql-libs-5.1.66-2.el6_3.x86_64
 
使用rpm -e来删除已经安装的mysql包,如果碰到不能报错不能删除,加上参数 --nodeps强制删除即可。
例如:
[root@suzzy ~]# rpm -e qt-mysql-4.6.2-25.el6.x86_64
error: Failed dependencies:
qt4-mysql is needed by (installed) akonadi-1.2.1-2.el6.x86_64
[root@suzzy ~]# rpm -e qt-mysql-4.6.2-25.el6.x86_64 --nodeps
 
rpm -e mysql-server-5.1.66-2.el6_3.x86_64 --nodeps
rpm -e dovecot-mysql-2.0.9-5.el6.x86_64 --nodeps
rpm -e qt-mysql-4.6.2-25.el6.x86_64 --nodeps
rpm -e rsyslog-mysql-5.8.10-6.el6.x86_64 --nodeps
rpm -e mysql-5.1.66-2.el6_3.x86_64 --nodeps
rpm -e mod_auth_mysql-3.0.0-11.el6_0.1.x86_64 --nodeps
rpm -e mysql-devel-5.1.66-2.el6_3.x86_64 --nodeps
rpm -e mysql-libs-5.1.66-2.el6_3.x86_64 --nodeps
 
直到执行下面语句找不到mysql包为止
[root@mysql01 ~]# rpm -qa | grep mysql
 
注意:在卸载完成之后需要删除配置文件/etc/my.cnf和数据库文件/var/lib/mysql ,保守起见可将配置文件my.cnf进行改名处理。
 

步骤二:开始安装
 
1、建立用户组及用户
[root@mysql01 ~]# groupadd mysql
[root@mysql01 ~]# useradd -g mysql mysql
 
2、将下载好的mysql程序rpm包上传至服务器
此处略过


[root@mysql01 Desktop]# unzip V76360-01.zip
[root@mysql01 Desktop]# rpm -ivh MySQL-*
Preparing...               ########################################### [100%]
  1:MySQL-devel-advanced  ########################################### [ 14%]
  2:MySQL-client-advanced ########################################### [ 29%]
   3:MySQL-test-advanced   ########################################### [ 43%]
  4:MySQL-embedded-advanced########################################### [ 57%]
  5:MySQL-shared-compat-adv########################################### [ 71%]
  6:MySQL-shared-advanced ########################################### [ 86%]
  7:MySQL-server-advanced ########################################### [100%]
2015-08-28 10:56:58 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-08-28 10:56:58 0 [Note] /usr/sbin/mysqld (mysqld 5.6.25-enterprise-commercial-advanced) starting as process 4981 ...
2015-08-28 10:56:58 4981 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-08-28 10:56:58 4981 [Note] InnoDB: The InnoDB memory heap is disabled
2015-08-28 10:56:58 4981 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-08-28 10:56:58 4981 [Note] InnoDB: Memory barrier is not used
2015-08-28 10:56:58 4981 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-08-28 10:56:58 4981 [Note] InnoDB: Using Linux native AIO
2015-08-28 10:56:58 4981 [Note] InnoDB: Using CPU crc32 instructions
2015-08-28 10:56:58 4981 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-08-28 10:56:58 4981 [Note] InnoDB: Completed initialization of buffer pool
2015-08-28 10:56:58 4981 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-08-28 10:56:58 4981 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-08-28 10:56:58 4981 [Note] InnoDB: Database physically writes the file full: wait...
2015-08-28 10:56:59 4981 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-08-28 10:57:00 4981 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-08-28 10:57:01 4981 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-08-28 10:57:01 4981 [Warning] InnoDB: New log files created, LSN=45781
2015-08-28 10:57:01 4981 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-08-28 10:57:01 4981 [Note] InnoDB: Doublewrite buffer created
2015-08-28 10:57:01 4981 [Note] InnoDB: 128 rollback segment(s) are active.
2015-08-28 10:57:01 4981 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-08-28 10:57:02 4981 [Note] InnoDB: Foreign key constraint system tables created
2015-08-28 10:57:02 4981 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-08-28 10:57:02 4981 [Note] InnoDB: Tablespace and datafile system tables created.
2015-08-28 10:57:02 4981 [Note] InnoDB: Waiting for purge to start
2015-08-28 10:57:02 4981 [Note] InnoDB: 5.6.25 started; log sequence number 0
2015-08-28 10:57:02 4981 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2015-08-28 10:57:02 4981 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
A random root password has been set. You will find it in '/root/.mysql_secret'.
2015-08-28 10:57:03 4981 [Note] Binlog end
2015-08-28 10:57:03 4981 [Note] InnoDB: FTS optimize thread exiting.
2015-08-28 10:57:03 4981 [Note] InnoDB: Starting shutdown...
2015-08-28 10:57:04 4981 [Note] InnoDB: Shutdown completed; log sequence number 1625977
 
 
2015-08-28 10:57:04 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-08-28 10:57:04 0 [Note] /usr/sbin/mysqld (mysqld 5.6.25-enterprise-commercial-advanced) starting as process 5006 ...
2015-08-28 10:57:04 5006 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-08-28 10:57:04 5006 [Note] InnoDB: The InnoDB memory heap is disabled
2015-08-28 10:57:04 5006 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-08-28 10:57:04 5006 [Note] InnoDB: Memory barrier is not used
2015-08-28 10:57:04 5006 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-08-28 10:57:04 5006 [Note] InnoDB: Using Linux native AIO
2015-08-28 10:57:04 5006 [Note] InnoDB: Using CPU crc32 instructions
2015-08-28 10:57:04 5006 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-08-28 10:57:04 5006 [Note] InnoDB: Completed initialization of buffer pool
2015-08-28 10:57:04 5006 [Note] InnoDB: Highest supported file format is Barracuda.
2015-08-28 10:57:04 5006 [Note] InnoDB: 128 rollback segment(s) are active.
2015-08-28 10:57:04 5006 [Note] InnoDB: Waiting for purge to start
2015-08-28 10:57:04 5006 [Note] InnoDB: 5.6.25 started; log sequence number 1625977
2015-08-28 10:57:04 5006 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2015-08-28 10:57:04 5006 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2015-08-28 10:57:04 5006 [Note] Binlog end
2015-08-28 10:57:04 5006 [Note] InnoDB: FTS optimize thread exiting.
2015-08-28 10:57:04 5006 [Note] InnoDB: Starting shutdown...
2015-08-28 10:57:06 5006 [Note] InnoDB: Shutdown completed; log sequence number 1625987

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
 
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
 
Also, the account for the anonymous user has been removed.
 
In addition, you can run:
 
 /usr/bin/mysql_secure_installation
 
which will also give you the option of removing the test database.
This is strongly recommended for production servers.
 
See the manual for more instructions.
 
Please report any problems at http://bugs.mysql.com/
 
The latest information about MySQL is available on the web at
 
  http://www.mysql.com
 
Support MySQL by buying support/licenses at http://shop.mysql.com
 
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
 
[root@mysql01 Desktop]# cat /root/.mysql_secret
# The random password set for the root user at Fri Aug 28 10:57:02 2015 (local time): FY2X3PPff8VzaEn5
 
 
3、配置并启动mysql及设置开机自动启动

[root@mysql01 Desktop]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
[root@mysql01 Desktop]# ls -l /etc/my.cnf
-rwxr-xr-x. 1 root root 1126 Aug 28 11:09 /etc/my.cnf
[root@mysql01 Desktop]# ps -ef | grep mysql
root     5369  5167  0 11:10 pts/1    00:00:00 grep mysql
[root@mysql01 Desktop]# service mysql start
Starting MySQL..                                          [  OK  ]
[root@mysql01 Desktop]# service mysql status
MySQL running (5507)                                      [  OK  ]
 
[root@mysql01 Desktop]# chkconfig --list | grep mysql
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off
 
备注:如2、3、4为off,即mysql未设置为开机自动启动,可以使用如下方法设置
[root@mysql01 Desktop]# chkconfig --list | grep mysql
mysql           0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@mysql01 Desktop]# chkconfig --level 2345 mysql on
[root@mysql01 Desktop]# chkconfig --list | grep mysql
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off
 
 
4、登录系统:

[root@mysql01 ~]# mysql -uroot -p
Enter password:                       //密码为空
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.6.25-enterprise-commercial-advanced
 
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql> set password for root@'localhost'=password("66666");
Query OK, 0 rows affected (0.10 sec)
 
mysql> show databases;
+--------------------+
| Database       |
+--------------------+
| information_schema |
| mysql         |
| performance_schema |
| test         |
+--------------------+
4 rows in set (0.14 sec)
mysql> exit
Bye


备注:

MySQL 5.6版本之前,默认安装的数据库是可以直接连接,五需密码的,而进入5.6版本,建库后数据库管理员账户(即root)
 
默认就会有密码保护,并且初始密码设置也很严格,这也说明进入5.6版本后,在安全性设置方面有一定提高


[root@mysql01 ~]# mysql -uroot -p
Enter password:666666
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.6.25-enterprise-commercial-advanced
 
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
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.14 sec)


步骤三:升级
 
MySQL 5.6.25升级到5.6.26
 
升级安装:
1、停服务
[root@mysql01 Desktop]# service mysql status
[root@mysql01 Desktop]# service mysql stop
[root@mysql01 Desktop]# service mysql status
 
2、备份数据文件
[root@mysql01 Desktop]# mkdir /tmp/mbackup
[root@mysql01 Desktop]# cp /usr/my.cnf /tmp/mbackup -a
[root@mysql01 Desktop]# mkdir /tmp/mbackup/data
[root@mysql01 Desktop]# cp -rp /var/lib/mysql/* /tmp/mbackup/data
 
3、解压缩升级版本安装源
[root@mysql01 Desktop]# unzip V77245-01.zip
[root@mysql01 Desktop]# rpm -ivh MySQL-*-5.6.26-* --replacefiles  
 
 
4、升级后更新数据字典
[root@mysql01 Desktop]# service mysql status
MySQL is not running                                      [FAILED]
[root@mysql01 Desktop]# service mysql start
Starting MySQL...                                         [  OK  ]
[root@mysql01 Desktop]# service mysql status
MySQL running (19134)                                     [  OK  ]
[root@mysql01 Desktop]# /usr/bin/mysql_upgrade -S /var/lib/mysql/mysql.sock -uroot -p666666  //操作前一定要确保mysql服务处于启动状态
Warning: Using a password on the command line interface can be insecure.
Looking for 'mysql' as: /usr/bin/mysql
Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Running 'mysqlcheck' with connection arguments: '--socket=/var/lib/mysql/mysql.sock'
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--socket=/var/lib/mysql/mysql.sock'
Warning: Using a password on the command line interface can be insecure.
mysql.columns_priv                                OK
mysql.db                                          OK
mysql.event                                       OK
mysql.func                                        OK
mysql.general_log                                 OK
mysql.help_category                               OK
mysql.help_keyword                                OK
mysql.help_relation                               OK
mysql.help_topic                                  OK
mysql.innodb_index_stats                          OK
mysql.innodb_table_stats                          OK
mysql.ndb_binlog_index                            OK
mysql.plugin                                      OK
mysql.proc                                        OK
mysql.procs_priv                                  OK
mysql.proxies_priv                                OK
mysql.servers                                     OK
mysql.slave_master_info                           OK
mysql.slave_relay_log_info                        OK
mysql.slave_worker_info                           OK
mysql.slow_log                                    OK
mysql.tables_priv                                 OK
mysql.time_zone                                   OK
mysql.time_zone_leap_second                       OK
mysql.time_zone_name                              OK
mysql.time_zone_transition                        OK
mysql.time_zone_transition_type                   OK
mysql.user                                        OK
Running 'mysql_fix_privilege_tables'...
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--socket=/var/lib/mysql/mysql.sock'
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--socket=/var/lib/mysql/mysql.sock'
Warning: Using a password on the command line interface can be insecure.
OK
 
 
5、检查确认

[root@mysql01 ~]# mysql -uroot -p
Enter password:666666
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.6.25-enterprise-commercial-advanced
 
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> select version();
+---------------------------------------+
| version()                    |
+---------------------------------------+
| 5.6.26-enterprise-commercial-advanced |
+---------------------------------------+
1 row in set (0.00 sec)
 
mysql> show databases;
+--------------------+
| Database       |
+--------------------+
| information_schema |
| mydata         |
| mysql         |
| performance_schema |
| test          |
| test_db        |
+--------------------+
6 rows in set (0.00 sec)

看完了这篇文章,相信你对“MySQL 5.5.25如何使用rpm安装及升级到5.6.26 for RedHat Enterprise Linux 6.4”有了一定的了解,如果想了解更多相关知识,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


网站题目:MySQL5.5.25如何使用rpm安装及升级到5.6.26forRedHatEnterpriseLinux6.4
网站路径:http://azwzsj.com/article/jeescc.html