在 CentOS 6.2 中将 MySQL 版本从 5.1 更新到 5.5
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9361720/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Update MySQL version from 5.1 to 5.5 in CentOS 6.2
提问by Dilip Rajkumar
I tried to update MySQL from 5.1 to 5.5 in CentOS 6.2. The following is the process I did:
我尝试在 CentOS 6.2 中将 MySQL 从 5.1 更新到 5.5。以下是我做的过程:
1. rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
2. yum install libmysqlclient15 --enablerepo=webtatic
3. yum remove mysql mysql-*
4. yum install mysql55 mysql55-server --enablerepo=webtatic
When I tried the 4th step, I got the following output:
当我尝试第 4 步时,得到以下输出:
[root@d2005 /]# yum install mysql55 mysql55-server --enablerepo=webtatic
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
* base: yum.singlehop.com
* extras: centos.mirrors.tds.net
* updates: pubmirrors.reflected.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql55.x86_64 0:5.5.10-1.w5 will be installed
--> Processing Dependency: mysql55-libs = 5.5.10-1.w5 for package: mysql55-5.5.10-1.w5.x86_64
---> Package mysql55-server.x86_64 0:5.5.10-1.w5 will be installed
--> Processing Dependency: perl-DBD-MySQL for package: mysql55-server-5.5.10-1.w5.x86_64
--> Running transaction check
---> Package mysql55-libs.x86_64 0:5.5.10-1.w5 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.61-1.el6_2.1 will be installed
--> Processing Conflict: mysql55-libs-5.5.10-1.w5.x86_64 conflicts mysql-libs < 5.5.10
--> Finished Dependency Resolution
Error: mysql55-libs conflicts with mysql-libs
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
How to fix it?
如何解决?
回答by Dilip Rajkumar
To list Old MySql
列出旧的 MySql
yum list installed | grep -i mysql
To remove Old MySql
删除旧的 MySql
yum remove mysql mysql-*
Remi Dependency on CentOS 6 and Red Hat (RHEL) 6
Remi 依赖 CentOS 6 和 Red Hat (RHEL) 6
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Install MySQL server
安装 MySQL 服务器
yum --enablerepo=remi,remi-test install mysql mysql-server
To list New MySql
列出新的 MySql
yum list installed | grep -i mysql
start MySql server
启动 MySql 服务器
/etc/init.d/mysqld start
## use restart after update
/etc/init.d/mysqld start
##更新后使用重启
OR
或者
service mysqld start
## use restart after update
service mysqld start
##更新后使用重启
chkconfig --levels 235 mysqld on
Last
最后的
mysql_upgrade -u root -p
Now my MySql version is 5.5.32
现在我的 MySql 版本是 5.5.32
Ref:
参考:
http://www.webtatic.com/packages/mysql55/
http://www.webtatic.com/packages/mysql55/
http://www.if-not-true-then-false.com/2010/install-mysql-on-fedora-centos-red-hat-rhel/
http://www.if-not-true-then-false.com/2010/install-mysql-on-fedora-centos-red-hat-rhel/
Hope it help some one
希望它帮助某人
NOTE:Adding comments from @pim (in comments)
注意:从@pim 添加评论(在评论中)
Just wanted to add that after the upgrade, my crontab was removed as well. Had to reinstall with "yum install vixie-cron" (CentOS 6)
回答by Drahcir
I used the following commands to add a new YUM repo and make the update:
我使用以下命令添加新的 YUM 存储库并进行更新:
Download the Remi repo
下载 Remi 仓库
cd /etc/yum.repos.d
wget http://rpms.famillecollet.com/enterprise/remi.repo
Install/Update the mysql version
安装/更新mysql版本
yum --enablerepo=remi install mysql-server
OR
或者
yum --enablerepo=remi update mysql-server
回答by Andy
You appear to have been using the wrong Webtatic Yum repository version than the one for your version of CentOS. See http://www.webtatic.com/projects/yum-repository/for details
您似乎使用了错误的 Webtatic Yum 存储库版本,而不是您的 CentOS 版本。见http://www.webtatic.com/projects/yum-repository/详细信息
e.g.
例如
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
You can use a yum plugin made by the IUS community to switch mysql-libs with mysql55w-libs. (the following assuming you still use Webtatic)
您可以使用 IUS 社区制作的 yum 插件将 mysql-libs 与 mysql55w-libs 切换。(以下假设您仍然使用 Webtatic)
yum install mysql yum-plugin-replace
yum replace mysql --replace-with mysql55w
That should allow you to replace mysql with mysql55w-libs, whilst maintaining the older libmysqlclient for any dependencies.
这应该允许您用 mysql55w-libs 替换 mysql,同时为任何依赖项保留旧的 libmysqlclient。
If you see other packages than mysql being removed, then be careful, as they might be needed, but using this method, I've found to be reliable whenever I've used it.
如果您看到除 mysql 之外的其他软件包被删除,请小心,因为它们可能是需要的,但是使用这种方法,我发现无论何时使用它都是可靠的。
I'm posting this solution as Remi's repository is not always the ideal solution. This method is more complex, but would never cause you to accidentally update your entire web stack by using repositories that use package names matching base distribution packages.
我发布此解决方案是因为 Remi 的存储库并不总是理想的解决方案。这种方法更复杂,但永远不会导致您通过使用使用与基本分发包匹配的包名称的存储库来意外更新整个 Web 堆栈。
回答by Raphvanns
2015/08/19 - For those of you working on older (but still decent) hardware with a matching OS (typically 32 bit machines).
2015/08/19 - 对于那些使用具有匹配操作系统(通常是 32 位机器)的旧(但仍然不错)硬件的人。
-- This will upgrade to mysql 5.6 community not 5.5 --
-- 这将升级到 mysql 5.6 社区而不是 5.5 --
This worked for me after some research and mixing/matching/testing the answers found on various page of the internet (mainly from this page and http://dev.mysql.com/doc/refman/5.6/en/linux-installation-yum-repo.html). My OS shipped with mysql 5.1, I wanted to have 5.6.
经过一些研究和混合/匹配/测试在互联网的各个页面上找到的答案后,这对我有用(主要来自此页面和http://dev.mysql.com/doc/refman/5.6/en/linux-installation- yum-repo.html)。我的操作系统附带 mysql 5.1,我想要 5.6。
My system
我的系统
[root@host]# cat /etc/*release
CentOS release 6.7 (Final)
[root@host]# uname -a
Linux host 2.6.32-573.3.1.el6.i686 #1 SMP Thu Aug 13 19:58:36 UTC 2015 i686 i686 i386 GNU/Linux
[root@host]# arch
i686
This is installed on a 2006 mac pro 1.1 (CPUs upgraded to 3.0GHz Intel Xeon X5365 Quad-Core).
它安装在 2006 mac pro 1.1(CPU 升级到 3.0GHz Intel Xeon X5365 Quad-Core)上。
Commands I ran
我运行的命令
This was done almost immediately after a fresh install of the OS and system update via yum
这几乎是在通过 yum 全新安装操作系统和系统更新后立即完成的
list mysql currently installed
列出当前安装的mysql
yum list installed | grep -i mysql
remove installed msql
删除已安装的 msql
yum remove mysql mysql-*
list mysql currently installed
列出当前安装的mysql
yum list installed | grep -i mysql
Download rpm containing mysql 5.6
下载包含mysql 5.6的rpm
wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
Install mysql
安装mysql
rpm -Uvh mysql-community-release-el6-5.noarch.rpm
yum install mysql mysql-server
list mysql currently installed
列出当前安装的mysql
yum list installed | grep -i mysql
ensure mysql starts on reboot
确保 mysql 在重启时启动
chkconfig --list mysqld
sudo chkconfig mysqld on
chkconfig --list mysqld
Start mysql
启动mysql
service mysqld start
service mysqld status
Result
结果
[root@host]# yum list installed | grep -i mysql
compat-mysql51.i686 5.1.54-1.el6.remi @remi
mysql-community-client.i686
5.6.26-2.el6 @mysql56-community
mysql-community-common.i686
5.6.26-2.el6 @mysql56-community
mysql-community-libs.i686
5.6.26-2.el6 @mysql56-community
mysql-community-release.noarch
mysql-community-server.i686
5.6.26-2.el6 @mysql56-community
perl-DBD-MySQL.i686 4.013-3.el6 @base
[root@host]# mysql --version
mysql Ver 14.14 Distrib 5.6.26, for Linux (i686) using EditLine wrapper
mysql config (I did not touch this yet but the info seems legit)
mysql 配置(我还没有接触过这个,但信息似乎是合法的)
一些有趣的基本但有效的 mysql 性能调整:Good luck!
祝你好运!
Edit
编辑
I had some issues creating users and granting permissions, this how it was fixed.
我在创建用户和授予权限时遇到了一些问题,这是如何解决的。
Error
错误
ERROR 1054 (42S22) at line 1: Unknown column 'plugin' in 'mysql.user'
Fix
使固定
- Logged on the server as root
- Connected to mysql with a simple
mysql
- Checked the outcome of this statement:
SELECT COUNT(1) column_count FROM information_schema.columns WHERE table_schema='mysql' AND table_name='user';
The result was 39, 43 is expected for mysql 5.6 - Issued this statement to update the root password:
update mysql.user set Password=PASSWORD('root') where User='root';
- (Logged off mysql with
exit
) - Restarted mysql with:
service mysqld restart
- Ran:
mysql_upgrade -uroot -proot --force
- Reconnected to mysql with
mysql -uroot -proot
- Checked the outcome of this statement:
SELECT COUNT(1) column_count FROM information_schema.columns WHERE table_schema='mysql' AND table_name='user';
The result was 43 as expected for mysql 5.6. I was then able to create my users and grant permissions as needed.
- 以 root 身份登录服务器
- 用一个简单的连接到mysql
mysql
- 检查此语句
SELECT COUNT(1) column_count FROM information_schema.columns WHERE table_schema='mysql' AND table_name='user';
的结果:结果为 39,mysql 5.6 预期为 43 - 发出此语句以更新 root 密码:
update mysql.user set Password=PASSWORD('root') where User='root';
- (用 注销 mysql
exit
) - 使用以下命令重新启动 mysql:
service mysqld restart
- 冉:
mysql_upgrade -uroot -proot --force
- 重新连接到mysql
mysql -uroot -proot
- 检查此语句
SELECT COUNT(1) column_count FROM information_schema.columns WHERE table_schema='mysql' AND table_name='user';
的结果:结果为 43,正如 mysql 5.6 所预期的那样。然后我就可以创建我的用户并根据需要授予权限。
回答by Quest Monger
Above replies didn't work for me (got this error - error: /var/tmp/rpm-tmp.tyukGy: not an rpm package).
以上回复对我不起作用(出现此错误 - 错误:/var/tmp/rpm-tmp.tyukGy: not an rpm package)。
I followed these steps -
我按照这些步骤 -
## Remove existing/old MySQL ##
yum remove mysql mysql-*
rm -rf /var/lib/mysql
rm -rf /var/log/mysql*
## Install Remi Repository on RHEL/CentOS 6.7-6.0 ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
## Install Remi Repository on RHEL/CentOS 5.4-5.0 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
yum --enablerepo=remi list mysql mysql-server
yum --enablerepo=remi install mysql mysql-server
Taken from - http://www.tecmint.com/install-mysql-on-rhel-centos-6-5-fedora-17-12/
取自 - http://www.tecmint.com/install-mysql-on-rhel-centos-6-5-fedora-17-12/
By doing above, i uninstalled MySQL 5.0.* and replaced it with this -
通过以上操作,我卸载了 MySQL 5.0.* 并将其替换为 -
[root@localhost]# /usr/bin/mysqladmin -u root -p version
/usr/bin/mysqladmin Ver 8.42 Distrib 5.5.28, for Linux on x86_64
Copyright (c) 2000, 2012, 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.
Server version 5.5.28
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 32 sec
Threads: 1 Questions: 3 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.093
[root@localhost]#
My CentOS version -
我的 CentOS 版本 -
[root@localhost]# cat /etc/redhat-release
CentOS release 6.3 (Final)
[root@localhost]# uname -a
Linux localhost.localdomain 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 23:43:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
回答by C.M.Chiu
Use CentOS-Release-SCL is better and easy.
使用 CentOS-Release-SCL 更好更容易。
The Software Collections ( SCL ) Repository
# yum install centos-release-SCL
# yum install mysql55-mysql-server
Done.
完毕。
回答by Toddius Zho
This blog posthelped me upgrade from MySQL 5.5.15 to 5.5.28. That upgrade also had the problem with mysql-libs
clashing with mysql55-libs
.
这篇博文帮助我从 MySQL 5.5.15 升级到 5.5.28。该升级也存在mysql-libs
与mysql55-libs
.
回答by lanni654321
wget -P /etc/yum.repos.d http://rpms.famillecollet.com/enterprise/remi.repo
yum --enablerepo=remi -y install mysql-server
OR
yum --enablerepo=remi -y update mysql-server