Centos6.7下安装mysql5.5.54

时间:2021-10-19 10:06:08


一、刚安装完的Linux系统中

要先确保已经运行了以下命令:

yum -y install gcc gcc-c++ gdb
yum install libtool


二、妈了个蛋,在发布该篇文章前,对于网上那些对于安装mysql的过程中报错的瞎鸡巴评论和答案表示不满,网上百度的东西水客越来越多。。。

@1、首先确保自己使用的Linux版本,我的是:Centos 6.7

@2、安装mysql版本请选用以下版本,不然你会瞎折腾一段时间的,这个我自己深有体会

平台选用:Linux-Generic

版本选用:MySQL-5.5.54-1.linux2.6.x86_64.rpm-bundle.tar

Centos6.7下安装mysql5.5.54


@3、将下载好的mysql上传到Linux系统上,进行解压

tar -xvf  MySQL-5.5.54-1.linux2.6.x86_64.rpm-bundle.tar


Centos6.7下安装mysql5.5.54


@4、解压后文件如下图所示,我们只需要按以下顺序,安装以下三个rpm

MySQL-client-5.5.54-1.linux2.6.x86_64.rpm

MySQL-devel-5.5.54-1.linux2.6.x86_64.rpm

MySQL-server-5.5.54-1.linux2.6.x86_64.rpm


命令:rpm -ivh MySQL-client-5.5.54-1.linux2.6.x86_64.rpm

Centos6.7下安装mysql5.5.54


命令:rpm -ivh MySQL-devel-5.5.54-1.linux2.6.x86_64.rpm

Centos6.7下安装mysql5.5.54


命令:rpm -ivh MySQL-server-5.5.54-1.linux2.6.x86_64.rpm

安装该文件时报一下错误,根据提示是mysql-libs-5.1.73包跟我们的安装文件版本冲突了,所以要删除该文件

Centos6.7下安装mysql5.5.54


使用命令:rpm -e --nodeps mysql-libs-5.1.73 ,删除掉该文件

Centos6.7下安装mysql5.5.54


然后重新执行命令:rpm -ivh MySQL-server-5.5.54-1.linux2.6.x86_64.rpm,见下图安装成功,并根据提示,去到对应安装目录下创建管理员和密码。

Centos6.7下安装mysql5.5.54


@5、根据提示切换到对应目录创建用户,报以下错误,是因为还没启动mysql服务

查看mysql启动状态:service mysql status

启动mysql服务:service mysql start

到对应目录:/usr/bin 执行命令:mysqladmin -u root password ‘密码’,创建管理员和密码

Centos6.7下安装mysql5.5.54

@6最后启动mysql服务后,登陆mysql

在命令台输入:mysql -u root -p回车,输入密码即登陆mysql了

Centos6.7下安装mysql5.5.54


三、注意事项

@3.1、启动mysql服务前,要确保防火墙已经开通了mysql的端口(默认3306),可以设置开通该端口

修改/etc/sysconfig/iptables 文件,添加以下内容: 

-A INPUT -m state --state NEW -m tcp -p tcp --dport
3306 -j ACCEPT

Centos6.7下安装mysql5.5.54


@3.2、安装过程报以下错误,呵呵,不要去百度为什么了,那些他妈的全是水客评论,都不是问题解决的重点,重点就在于你下载的版本是否跟我上面的一样,重新下载个版本,选择以下版本重新安装就可以了。

平台选用:Linux-Generic

版本选用:MySQL-5.5.54-1.linux2.6.x86_64.rpm-bundle.tar


error: Failed dependencies:
libc.so.6()(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libc.so.6(GLIBC_2.11)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libc.so.6(GLIBC_2.2.5)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libc.so.6(GLIBC_2.3)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libc.so.6(GLIBC_2.3.4)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libc.so.6(GLIBC_2.4)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libdl.so.2()(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libdl.so.2(GLIBC_2.2.5)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libgcc_s.so.1()(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libgcc_s.so.1(GCC_3.0)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libm.so.6()(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libm.so.6(GLIBC_2.2.5)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libncurses.so.5()(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libpthread.so.0()(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libpthread.so.0(GLIBC_2.2.5)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libpthread.so.0(GLIBC_2.3.2)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
librt.so.1()(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
librt.so.1(GLIBC_2.2.5)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libstdc++.so.6()(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libstdc++.so.6(CXXABI_1.3)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libstdc++.so.6(GLIBCXX_3.4)(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64
libtinfo.so.5()(64bit) is needed by MySQL-client-5.6.20-1.el6.x86_64 

@3.3、启动mysql远程访问

需要新创建一个用户,并分配相应权限给它,如下

grant all privileges on *.* to admin@"%" identified by 'password' with grant option

Centos6.7下安装mysql5.5.54


分配完刷新,使修改生效

Centos6.7下安装mysql5.5.54


@3.4、解决mysql中文乱码问题


Centos6.7下安装mysql5.5.54

进入my.cnf文件,做以下修改

[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect=
'SET NAMES utf8′
character-set-server = utf8
修改后
关闭数据库:

service mysql stop
然后重新启动mysql:

service mysql start



-------------------------------------接着问题就来了

发现window上显示的字符编码和虚拟机上Linux上显示的字符编码不一致,而且还是不能插入中文。
如下所示:

用window远程连接工具访问虚拟机上的mysql,用命令:

SHOW VARIABLES LIKE "character%";

window上字符编码显示如下:

Centos6.7下安装mysql5.5.54


Linux上的mysql字符编码显示如下:

Centos6.7下安装mysql5.5.54


解决办法:

在创建新的database的时候加命令,例如:create database mydb character set utf8;

所以说网上查找的那些什么“”彻底解决mysql中文乱码问题,完美解决mysql中文乱码问题”都是屁话,根本就不通用,要根据每个人的实际环境做相应的修改。