MySQL 5.5.25如何安装及升级到5.6.26 for RedHat Enterprise Linux 6.4
这篇文章将为大家详细讲解有关MySQL 5.5.25如何安装及升级到5.6.26 for RedHat Enterprise Linux 6.4,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
步骤一:准备工作:
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@mysql01 Desktop]# 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 包名 (都地上面显示)来清除安装包,如果碰到不能报错不能删除,加上参数 --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 ~]# rpm -qa | grep cmake
cmake-2.6.4-5.el6.x86_64
[root@mysql01 ~]# rpm -qa | grep make
cmake-2.6.4-5.el6.x86_64
automake-1.11.1-4.el6.noarch
imake-1.0.2-11.el6.x86_64
make-3.81-20.el6.x86_64
makebootfat-1.4-10.el6.x86_64
[root@mysql01 ~]# yum install gcc gcc-c++ autoconf automake bison* zlib* libxml* ncurses-devel libaio* make cmake -y //如果加测没有安装make、cmake包需要安装
2、安装libtool-ltdl-devel包(libtool-ltdl-devel-2.2.6-15.5.el6.i686.rpm、libtool-ltdl-devel-2.2.6-15.5.el6.x86_64.rpm)
[root@mysql01 ~]# cd /misc/cd/Packages
[root@mysql01 Packages]# ls -l libtool-ltdl*
-r--r--r--. 144 root root 45660 Aug 17 2010 libtool-ltdl-2.2.6-15.5.el6.i686.rpm
-r--r--r--. 109 root root 45460 Aug 17 2010 libtool-ltdl-2.2.6-15.5.el6.x86_64.rpm
-r--r--r--. 37 root root 166264 Aug 17 2010 libtool-ltdl-devel-2.2.6-15.5.el6.i686.rpm
-r--r--r--. 34 root root 166248 Aug 17 2010 libtool-ltdl-devel-2.2.6-15.5.el6.x86_64.rpm
[root@mysql01 Packages]# rpm -ivh libtool-ltdl-2.2.6-15.5.el6.i686.rpm
warning: libtool-ltdl-2.2.6-15.5.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:libtool-ltdl ########################################### [100%]
[root@mysql01 Packages]# rpm -ivh libtool-ltdl-devel-2.2.6-15.5.el6.i686.rpm //安装这个包之前先安装rpm -ivh libtool-ltdl-2.2.6-15.5.el6.i686.rpm
warning: libtool-ltdl-devel-2.2.6-15.5.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:libtool-ltdl-devel ########################################### [100%]
[root@mysql01 Packages]# rpm -ivh libtool-ltdl-devel-2.2.6-15.5.el6.i686.rpm
warning: libtool-ltdl-devel-2.2.6-15.5.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:libtool-ltdl-devel ########################################### [100%]
备注:
笔者在很多地方看到MySQL时使用的是libtool-ltdl-devel*,在使用yum安装时会报如下错误:
在MySQL的安装过程中,libtool-ltdl-devel-2.2.6-15.5.el6.x86_64.rpm可以用rpm -ivh libtool-ltdl-devel-2.2.6-15.5.el6.x86_64.rpm方式安装,
但是用yum install libtool-ltdl-devel*就会报错,若你想连libtool-ltdl-devel-2.2.6-15.5.el6.i686.rpm一起装安装,就必须先安装
libtool-ltdl-2.2.6-15.5.el6.i686.rpm包,然后才能安装rpm -ivh libtool-ltdl-devel-2.2.6-15.5.el6.i686.rpm
以下为报错信息:
[root@mysql01 ~]# yum install gcc gcc-c++ autoconf automake bison* zlib* libxml* ncurses-devel libaio* libtool-ltdl-devel* make cmake -y
Loaded plugins: aliases, changelog, downloadonly, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo,
: verify, versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
Setting up Install Process
Package gcc-4.4.7-3.el6.x86_64 already installed and latest version
Package gcc-c++-4.4.7-3.el6.x86_64 already installed and latest version
............................................
Package ncurses-devel-5.7-3.20090208.el6.x86_64 already installed and latest version
No package libtool-ltdl-devel* available.
Package 1:make-3.81-20.el6.x86_64 already installed and latest version
.........................................................
即使你使用如下安装方法安装也会报错:
[root@mysql01 ~]# yum install libtool-ltdl-devel* -y
Loaded plugins: aliases, changelog, downloadonly, kabi, presto, product-id, refresh-packagekit,
: security, subscription-manager, tmprepo, verify, versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
Setting up Install Process
No package libtool-ltdl-devel* available.
Error: Nothing to do
[root@mysql01 ~]# yum install libtool-ltdl-devel-2.2.6-15.5.el6.i686* -y
Loaded plugins: aliases, changelog, downloadonly, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo,
: verify, versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
Setting up Install Process
No package libtool-ltdl-devel-2.2.6-15.5.el6.i686* available.
Error: Nothing to do
[root@mysql01 ~]# rpm -ivh /misc/cd/Packages/libtool-ltdl-devel-2.2.6-15.5.el6.i686.rpm
warning: /misc/cd/Packages/libtool-ltdl-devel-2.2.6-15.5.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
libltdl.so.7 is needed by libtool-ltdl-devel-2.2.6-15.5.el6.i686
3、建立用户组及用户
[root@mysql01 ~]# groupadd mysql
[root@mysql01 ~]# useradd -g mysql mysql
4、设置操作系统资源限制
[root@mysql01 ~]# vi /etc/security/limits.conf //在配置文件最末尾添加如下内容
mysql soft nproc 2047
mysql hard nproc 16384
mysql soft nofile 1024
mysql hard nofile 65536
5、将下载好的mysql程序rpm包上传至服务器
此处略过
6、创建mysql的安装目录及数据库存放目录并设置权限
[root@mysql01 ~]# mkdir -p /usr/local/mysql
[root@mysql01 ~]# mkdir -p /usr/local/mysql/data
[root@mysql01 ~]# chown -R mysql:mysql /usr/local/mysql/
7、解压上传好mysql源文件
[root@mysql01 ~]# cd Desktop
[root@mysql01 Desktop]# tar -xzvf mysql-5.6.25.tar.gz -C /usr/local/mysql
[root@mysql01 Desktop]# chown -R mysql:mysql /usr/local/mysql/
8、执行cmake命令,生成编译配置文件
[root@mysql01 ~]# cd /usr/local/mysql/mysql-5.6.25/
[root@mysql01 mysql-5.6.25]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DINSTALL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1
[root@mysql01 mysql-5.6.25]# make && make install
备注:
1、此编译安装过程耗时较慢,可能耗时5-10分钟左右,需要大家耐心等待.
2、CMAKE参数说明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //默认安装目录
-DINSTALL_DATADIR=/usr/local/mysql/data //数据库存放目录
-DDEFAULT_CHARSET=utf8 //使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci //校验字符
-DEXTRA_CHARSETS=all //安装所有扩展字符集
-DENABLED_LOCAL_INFILE=1 //允许从本地导入数据
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
注意事项:
如安装失败重新编译时,需要清除旧的对象文件和缓存信息。
shell> make clean
shell> rm -f CMakeCache.txt
shell> rm -rf /etc/my.cnf
9、设置开机自动启动及创建系统数据库的表
[root@mysql01 ~]# cp /usr/local/mysql/mysql-5.6.25/support-files/my-default.cnf /etc/my.cnf
[root@mysql01 ~]# cp /usr/local/mysql/mysql-5.6.25/support-files/mysql.server /etc/rc.d/init.d/mysql //将mysql的启动服务添加到系统服务中
10、安装mysql数据库:
[root@mysql01 ~]# chmod +x /usr/local/mysql/mysql-5.6.25/scripts/mysql_install_db*
[root@mysql01 ~]# /usr/local/mysql/mysql-5.6.25/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
或者:
[root@mysql01 ~]# /usr/local/mysql/mysql-5.6.25/scripts/mysql_install_db.sh --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
或者:
[root@mysql01 scripts]# ./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
Installing MySQL system tables...2016-01-12 14:16:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-12 14:16:46 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.25) starting as process 4236 ...
2016-01-12 14:16:46 4236 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-12 14:16:46 4236 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-12 14:16:46 4236 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-12 14:16:46 4236 [Note] InnoDB: Memory barrier is not used
2016-01-12 14:16:46 4236 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-12 14:16:46 4236 [Note] InnoDB: Using Linux native AIO
2016-01-12 14:16:46 4236 [Note] InnoDB: Using CPU crc32 instructions
2016-01-12 14:16:46 4236 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-12 14:16:46 4236 [Note] InnoDB: Completed initialization of buffer pool
2016-01-12 14:16:46 4236 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-01-12 14:16:46 4236 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-01-12 14:16:46 4236 [Note] InnoDB: Database physically writes the file full: wait...
2016-01-12 14:16:46 4236 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-01-12 14:16:47 4236 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-01-12 14:16:48 4236 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-01-12 14:16:48 4236 [Warning] InnoDB: New log files created, LSN=45781
2016-01-12 14:16:48 4236 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-01-12 14:16:48 4236 [Note] InnoDB: Doublewrite buffer created
2016-01-12 14:16:48 4236 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-12 14:16:48 4236 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-01-12 14:16:48 4236 [Note] InnoDB: Foreign key constraint system tables created
2016-01-12 14:16:48 4236 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-01-12 14:16:48 4236 [Note] InnoDB: Tablespace and datafile system tables created.
2016-01-12 14:16:48 4236 [Note] InnoDB: Waiting for purge to start
2016-01-12 14:16:48 4236 [Note] InnoDB: 5.6.25 started; log sequence number 0
2016-01-12 14:16:49 4236 [Note] Binlog end
2016-01-12 14:16:49 4236 [Note] InnoDB: FTS optimize thread exiting.
2016-01-12 14:16:49 4236 [Note] InnoDB: Starting shutdown...
2016-01-12 14:16:51 4236 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2016-01-12 14:16:51 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-12 14:16:51 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.25) starting as process 4260 ...
2016-01-12 14:16:51 4260 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-12 14:16:51 4260 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-12 14:16:51 4260 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-12 14:16:51 4260 [Note] InnoDB: Memory barrier is not used
2016-01-12 14:16:51 4260 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-12 14:16:51 4260 [Note] InnoDB: Using Linux native AIO
2016-01-12 14:16:51 4260 [Note] InnoDB: Using CPU crc32 instructions
2016-01-12 14:16:51 4260 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-12 14:16:51 4260 [Note] InnoDB: Completed initialization of buffer pool
2016-01-12 14:16:51 4260 [Note] InnoDB: Highest supported file format is Barracuda.
2016-01-12 14:16:51 4260 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-12 14:16:51 4260 [Note] InnoDB: Waiting for purge to start
2016-01-12 14:16:51 4260 [Note] InnoDB: 5.6.25 started; log sequence number 1625977
2016-01-12 14:16:51 4260 [Note] Binlog end
2016-01-12 14:16:51 4260 [Note] InnoDB: FTS optimize thread exiting.
2016-01-12 14:16:51 4260 [Note] InnoDB: Starting shutdown...
2016-01-12 14:16:53 4260 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h mysql01 password 'new-password'
Alternatively you can run:
/usr/local/mysql/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.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
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/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
11、启动mysql数据库并设置开机自动启动:
[root@mysql01 ~]# service mysql start
env: /etc/init.d/mysql: Permission denied
[root@mysql01 ~]# ls -l /etc/init.d/mysql
-rw-r--r--. 1 root root 10880 Aug 28 21:24 /etc/init.d/mysql
[root@mysql01 ~]# chmod 755 /etc/init.d/mysql
[root@mysql01 ~]# ls -l /etc/init.d/mysql
-rwxr-xr-x. 1 root root 10880 Aug 28 21:24 /etc/init.d/mysql
[root@mysql01 ~]# service mysql status
MySQL is not running [FAILED]
[root@mysql01 ~]# service mysql start
Starting MySQL.. [ OK ]
[root@mysql01 Desktop]# chkconfig --list | grep mysql
[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
12、将mysql的启动服务添加到系统服务中
[root@mysql01 ~]# vi /root/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
[root@mysql01 ~]# source /root/.bash_profile
或者:
[root@mysql01 ~]# . .bash_profile
13、登录测试:
[root@mysql01 ~]# mysql -uroot -p
Enter password: //密码为空
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.25 Source distribution
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> set password for root@'localhost'=password("666666");
Query OK, 0 rows affected (0.04 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| t |
+--------------------+
4 rows in set (0.03 sec)
mysql> select user,host from mysql.user order by user;
+------+-----------+
| user | host |
+------+-----------+
| | localhost |
| | mysql01 |
| root | localhost |
| root | mysql01 |
| root | 127.0.0.1 |
| root | ::1 |
+------+-----------+
6 rows in set (0.01 sec)
mysql> exit
Bye
[root@mysql01 ~]# mysql -uroot -p
Enter password:666666
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.25 Source distribution
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 |
| mysq |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
关于"MySQL 5.5.25如何安装及升级到5.6.26 for RedHat Enterprise Linux 6.4"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。