centos7安装mysq5.5

同步时间

    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 不同时区

命令是ntpdate

     ntp1.aliyun.com  (用)

    ntp2.aliyun.com
    ntp3.aliyun.com
    ntp4.aliyun.com
    ntp5.aliyun.com
    ntp6.aliyun.com
    ntp7.aliyun.com

 

 

 

centos7有默认的数据库首先我们需要删除掉

       rpm -qa | grep mariadb     //查看默认的mariadb的版本

#卸载mariadb-libs-5.5.37-1.el7_0.x86_64

rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64

错误:依赖检测失败:
        libmysqlclient.so.18()(64bit) 被 (已安裝) postfix-2:2.10.1-6.el7.x86_64 需要
        libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) postfix-2:2.10.1-6.el7.x86_64 需要

#强制卸载,因为没有--nodeps

rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64

 

 

官网说明

1. 下载 rpm 源

官网下载地址

因为是 CentOS7 我选择的是Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package

  • 点击“download”
  • 弹出的下载页面,右键 “ No thanks, just start my download.” 复制链接

比如我复制下来是 :https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

mkdir /home/mysql
cd /home/mysql
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

2. 添加 yum mysql 的仓库

以下命名在 /home/mysql 目录下执行,或者加上目录路径执行也可

rpm -Uvh mysql57-community-release-el7-11.noarch.rpm

如果没有权限,用 sudo 执行

3. 自定义 mysql 安装的版本

3.1 查看当前可安装版本

yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community   disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community   disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
mysql-connectors-community/x86_64  MySQL Connectors Community    enabled:     45
mysql-connectors-community-source  MySQL Connectors Community -  disabled
mysql-tools-community/x86_64       MySQL Tools Community         enabled:     59
mysql-tools-community-source       MySQL Tools Community - Sourc disabled
mysql-tools-preview/x86_64         MySQL Tools Preview           disabled
mysql-tools-preview-source         MySQL Tools Preview - Source  disabled
mysql55-community/x86_64           MySQL 5.5 Community Server    disabled
mysql55-community-source           MySQL 5.5 Community Server -  disabled
mysql56-community/x86_64           MySQL 5.6 Community Server    disabled
mysql56-community-source           MySQL 5.6 Community Server -  disabled
mysql57-community/x86_64           MySQL 5.7 Community Server    enabled:    247
mysql57-community-source           MySQL 5.7 Community Server -  disabled
mysql80-community/x86_64           MySQL 8.0 Community Server    disabled
mysql80-community-source           MySQL 8.0 Community Server -  disabled

enabled,表示默认安装版本, 默认为5.7

3.2 修改安装版本

关闭5.7版本安装
yum-config-manager --disable mysql57-community
打开55版本安装
yum-config-manager --enable mysql55-community

yum-config-manager 无法执行,这个是因为系统默认没有安装这个命令,这个命令在yum-utils 包里,可以通过命令yum -y install yum-utils 安装就可以了

3.3 验证版本

yum repolist all | grep mysql

或者

yum repolist enabled | grep mysql

查看当前 enabled 的 mysql 版本,如果是你设置的版本。就可以安装了。

3.4 安装 mysql 5.5

yum install mysql-community-server

默认安装后的 mysql 是没有密码,请尽快设置。

set password for 'root'@'localhost' = PASSWORD('newpassword');

接下来设置mysql开机启动:

[root@wm001 ~]# systemctl enable mysqld.service

 

然后启动mysql:

[root@wm001 ~]# systemctl start mysqld

 

接下来,设置root用户密码:


GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;
*.* 表示所有库的所有表,root在所有主机(%任何主机)
delete from user where host != '%';
flush privileges;

退出quit重新登录 需要输入用户名 密码123
mysql -u root -p

qiut;   退出。
 

上一篇:HTML中基础元素(一)


下一篇:启动nginx 提示:nginx: [emerg] bind() to 0.0.0.0:8082 failed (13: Permission denied)