首页  >  文章  >  数据库  >  MySQL5.1如何在CentOS系统中升级至5.5.36的示例详解

MySQL5.1如何在CentOS系统中升级至5.5.36的示例详解

黄舟
黄舟原创
2017-07-17 14:34:231366浏览

有相关测试数据说明从5.1到5.5+,MySQL性能会有明显的提升,具体的需要自己建立测试环境去实践下,今天我们就来操作下,并记录下来升级的具体步骤

记录下CentOS 6.4环境将MySQL5.1升级至5.5.36的过程,希望对大家有个参考。

1.为了安全期间,首先需要备份原有数据

2.卸载原有MySQL,先停止原有的MySQL服务,再查找 find / -name mysql

[root@linuxidc /]# find / -name mysql

/var/lib/mysql

/var/lib/mysql/mysql

/usr/lib64/mysql

并移除服务

[root@linuxidc /]# rm -rf /var/lib/mysql

[root@linuxidc /]# rm -rf /var/lib/mysql

[root@linuxidc /]# rm -rf /usr/lib64/mysql

3.安装cmake

[root@linuxidc download]# wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz

[root@linuxidc download]# tarx zvfc cmake-2.8.12.2.tar.gz

[root@linuxidc download]# cd cmake-2.8.12.2

[root@linuxidc cmake-2.8.12.2]# ./configure

[root@linuxidc cmake-2.8.12.2]# make && make install

4.下载安装MySQL5.5.36

[root@linuxidc download]# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.36.tar.gz

[root@linuxidc download]# tar xzvf mysql-5.5.36.tar.gz

[root@linuxidc download]# cd mysql-5.5.36

[root@linuxidc mysql-5.5.36]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/home/mysql

[root@linuxidc mysql-5.5.36]# make && make install

在cmake的过程中出错了,提示Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)

执行以下代码就可以了,执行好之后继续cmake,然后再make && make install

[root@localhost mysql-5.5.36]# rm CMakeCache.txt
[root@localhost mysql-5.5.36]# yum install ncurses-devel

5.接下来需要把之前备份下来的my.cnf文件,复制至/etc/my.cnf

MySQL会读取/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf /.my.cnf。左边的文件优先级是最高的

6.配置好之后,我们就启动mysql,发现有一个问题启动MySQL提示:The server quit without updating PID file(…)失败

查看my.cnf文件设置的日记文件地址/var/log/mysqld.log,错误提示如下

170715 12:31:36 mysqld_safe mysqld from pid file /var/lib/mysql/linuxidc.pid ended
170715 12:57:48 mysqld_safe Starting mysqld daemon with databases from /home/mysql
170715 12:57:48 InnoDB: The InnoDB memory heap is disabled
170715 12:57:48 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170715 12:57:48 InnoDB: Compressed tables use zlib 1.2.3
170715 12:57:48 InnoDB: Initializing buffer pool, size = 128.0M
170715 12:57:48 InnoDB: Completed initialization of buffer pool
170715 12:57:48 InnoDB: highest supported file format is Barracuda.
170715 12:57:48  InnoDB: Waiting for the background threads to start
170715 12:57:49 InnoDB: 5.5.36 started; log sequence number 2645823
170715 12:57:49 [ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'default-character-set=utf8'
170715 12:57:49 [ERROR] Aborting

此报错是由/etc/my.cnf配置文件下的[mysqld]设置字符集引起的,解决方法:将default-character-set=utf8 改为 character_set_server=utf8

7.通过mysql -u root -p命令连接mysql。(我们之前有安装过mysql,数据库文件还在,所以不需要再添加用户设置权限了)

出现了错误信息:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

出错原因是我们mysql.sock文件在/usr/lib/mysql/文件夹下

可以尝试通过下面命令连接,并查看mysql版本

[root@linuxidc var]# mysql -u root -p -S /usr/lib/mysql/mysql.sock
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.5.36    |
+-----------+
1 row in set (0.00 sec)

以上是MySQL5.1如何在CentOS系统中升级至5.5.36的示例详解的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn