zoukankan      html  css  js  c++  java
  • 用rpm包在centos6.6安装mysql-5.7.29-1.el7.x86_64

    一,准备工作。

    查看系统版本:

    [root@localhost ~]# uname -a
    Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    [root@localhost ~]# cat /etc/redhat-release
    CentOS Linux release 7.4.1708 (Core) 
    [root@localhost ~]#

    mysql的rpm包下载地址

    https://dev.mysql.com/downloads/mysql/5.7.html#downloads

    下载,mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar 大小520.5M

    卸载CentOS7.4系统自带的mariadb

    [root@localhost ~]# rpm -qa|grep mysql
    mysql-5.1.73-8.el6_8.x86_64
    mysql-libs-5.1.73-8.el6_8.x86_64
    rpm -e --nodeps mysql-5.1.73-8.el6_8.x86_64
    [root@test01 ~]# rpm -e --nodeps mysql-libs-5.1.73-8.el6_8.x86_64
    [root@test01 ~]# rpm -qa|grep mysql
    [root@test01 ~]# cd /etc
    [root@test01 etc]# ll |grep my.cnf
    [root@test01 etc]# cat my.cnf
    cat: my.cnf: 没有那个文件或目录

    解压

    复制代码
    [root@localhost mysql]# tar xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar 
    [root@test01 mysql]# ll
    总用量 965308
    -rw-r--r--. 1 root root  494233600 5月  14 13:19 mysql-5.7.29-1.el6.x86_64.rpm-bundle.tar
    -rw-r--r--. 1 7155 31415  27089920 12月 19 03:12 mysql-community-client-5.7.29-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415    379072 12月 19 03:12 mysql-community-common-5.7.29-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415   4048564 12月 19 03:12 mysql-community-devel-5.7.29-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415  39677684 12月 19 03:12 mysql-community-embedded-5.7.29-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415 137631960 12月 19 03:12 mysql-community-embedded-devel-5.7.29-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415   2643576 12月 19 03:12 mysql-community-libs-5.7.29-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415   1761600 12月 19 03:12 mysql-community-libs-compat-5.7.29-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415 171445040 12月 19 03:12 mysql-community-server-5.7.29-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415 109539700 12月 19 03:12 mysql-community-test-5.7.29-1.el6.x86_64.rpm
    复制代码

    依次安装:

    mysql-community-common-5.7.29-1.el7.x86_64.rpm、
    mysql-community-libs-5.7.29-1.el7.x86_64.rpm、
    mysql-community-client-5.7.29-1.el7.x86_64.rpm、
    mysql-community-server-5.7.29-1.el7.x86_64.rpm

    安装common

    [root@test01 mysql]# rpm -ivh mysql-community-common-5.7.29-1.el6.x86_64.rpm 
    warning: mysql-community-common-5.7.29-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                ########################################### [100%]
       1:mysql-community-common ########################################### [100%]

    安装libs

    [root@test01 mysql]# rpm -ivh mysql-community-libs-5.7.29-1.el6.x86_64.rpm 
    warning: mysql-community-libs-5.7.29-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                ########################################### [100%]
       1:mysql-community-libs   ########################################### [100%]

    安装client

    [root@test01 mysql]# rpm -ivh mysql-community-client-5.7.29-1.el6.x86_64.rpm 
    warning: mysql-community-client-5.7.29-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                ########################################### [100%]
       1:mysql-community-client ########################################### [100%]

    安装server

    [root@test01 mysql]# rpm -ivh mysql-community-server-5.7.29-1.el6.x86_64.rpm 
    warning: mysql-community-server-5.7.29-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                ########################################### [100%]
       1:mysql-community-server ########################################### [100%]

    直接启动服务或初始化都会无法正常启动MySQL,错误如下

     1 [root@test01 mysql]# mysqld --initialize --user=mysql
     2 2020-05-15T09:47:59.588585Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
     3 2020-05-15T09:47:59.591022Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
     4 2020-05-15T09:47:59.591066Z 0 [ERROR] Aborting
     5 
     6 [root@test01 mysql]# service mysqld start
     7 初始化 MySQL 数据库: 2020-05-15T09:48:21.877088Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
     8 2020-05-15T09:48:21.879595Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
     9 2020-05-15T09:48:21.879633Z 0 [ERROR] Aborting
    10 
    11                                                            [失败]
    原因就是:安装完所有的程序后,系统会自带一个数据文件,如下:
    [root@test01 ~]# cd /etc
    [root@test01 etc]# cat my.cnf
    ......
    ......
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
     

    删除系统自带的/var/lib/mysql目录下的所有数据文件

    1 [root@test01 mysql]# rm -rf *
     

     查看防火墙端口,初始化MySQL

    复制代码

    [root@test01 mysql]# mysqld --initialize --user=mysql

    复制代码

    启动mysql服务

    service mysqld start

    设置数据库日志过期天数为14天

    获取mysql的root用户的初始密码

    [root@localhost ~]# grep 'password' /var/log/mysqld.log 
    2020-01-14T01:09:01.515663Z 1 [Note] A temporary password is generated for root@localhost: vx*biwua,8/Q
    [root@localhost ~]# 

    以获取mysql的root用户的初始密码登录数据库

    [root@localhost ~]# mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 5
    Server version: 5.7.29

    修改root密码

    mysql> alter user 'root'@'localhost' identified by '12345678';
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> 

    使密码即时生效

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> 

    允许以root身份远程登录mysql

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678' WITH GRANT OPTION;
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> 

    修改mysql的字符集为utf8
    编辑文件/etc/my.conf,设置字符集为utf8

    vi /etc/my.cnf

    重起mysql服务

    [root@localhost ~]# service mysqld restart
    Redirecting to /bin/systemctl restart mysqld.service
    [root@localhost ~]# 
  • 相关阅读:
    [转载]RTSP in Stagefright
    FFMPEG for WMA Build Script
    Merge AACExtractor from ICS to Froyo
    查看部署在Heroku上的项目信息
    About AudioSystem Mute
    C++标准转换运算符reinterpret_cast
    纯CSS动态效果的画廊
    基于正则表达式匹配的C++语法高亮度显示
    C++标准转换运算符static_cast
    C++标准转换运算符const_cast
  • 原文地址:https://www.cnblogs.com/accumulater/p/12893429.html
Copyright © 2011-2022 走看看