• CentOS 7.x 二进制方式安装mysql5.7.24


    1. 当前环境
    [root@test-mysql ~]# cat /etc/redhat-release
    CentOS Linux release 7.3.1611 (Core)
    
    1. 浏览器下载mysql安装包或者使用wget下载,并解压
    [root@test-mysql ~]# cd /usr/local/src
    [root@test-mysql src]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-el7-x86_64.tar.gz
    [root@test-mysql src]# tar xf mysql-5.7.24-el7-x86_64.tar.gz
    
    1. 创建软链接方便版本升级或者回退
    [root@test-mysql src]# ln -s /usr/local/src/mysql-5.7.24-el7-x86_64/ /usr/local/mysql
    
    1. 创建数据目录、用户并进行授权
    [root@test-mysql src]# useradd -M -s /sbin/nologin mysql
    [root@test-mysql src]# mkdir -p /server/data/mysql
    [root@test-mysql src]# mkdir -p /server/logs/mysql
    [root@test-mysql src]# chown -R mysql. /server/data/mysql /server/logs/mysql /usr/local/mysql /usr/local/src/mysql-5.7.24-el7-x86_64
    
    1. 将mysql命令目录添加至PATH环境变量。
    [root@test-mysql src]# echo 'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile
    [root@test-mysql src]# source /etc/profile
    
    1. 初始化mysql
    [root@test-mysql src]# mysqld --initialize --user=mysql --datadir=/server/data/mysql --basedir=/usr/local/mysql
    2021-03-04T08:11:06.244772Z 1 [Note] A temporary password is generated for root@localhost: S;(c8WqasNppTp
    ---------------------------------------------------------------------------------------------------------------------------------------------------------
    # 如报错 mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory,请安装:
    [root@test-mysql src]# yum -y install libaio
    ---------------------------------------------------------------------------------------------------------------------------------------------------------
    
    1. 编辑用户配置文件,尝试启动mysql
    [root@test-mysql src]# 
    m -r /etc/my.cnf.d
    [root@test-mysql src]# cp /etc/my.cnf{,.bak}
    [root@test-mysql src]# vim /etc/my.cnf
    [client]
    port=3306
    socket=/usr/local/mysql/mysql.sock
    
    [mysql]
    prompt="\u@\h \R:\m:\s [\d]> "
    
    [mysqld]
    user=mysql
    port=3306
    basedir=/usr/local/mysql
    datadir=/server/data/mysql
    socket=/usr/local/mysql/mysql.sock
    pid-file=/usr/local/mysql/mysqld.pid
    log-error=/server/logs/mysql/error.log
    character-set-server=utf8mb4
    
    1. 优化mysql启动方式,启动mysql。
    [root@test-mysql src]# cd /usr/local/mysql/support-files
    [root@test-mysql support-files]# cp mysql.server /etc/init.d/mysqld
    [root@test-mysql support-files]# /etc/init.d/mysqld start
    ---------------------------------------------------------------------------------------------------------------------------------------------------------
    # 若报错error: log-error set to '/server/logs/mysql/error.log',请手动创建:
    [root@test-mysql support-files]# 
    m /server/data/mysql/ib_logfile*
    [root@test-mysql support-files]# touch /server/logs/mysql/error.log
    [root@test-mysql support-files]# chown mysql. /server/logs/mysql/error.log
    --------------------------------------------------------------------------------------------------------------------------------------------------------- 
    
    1. 修改密码,开始使用。
    #修改密码需要先输入旧密码,旧密码在初始化mysql的时候有自动生成。
    [root@test-mysql support-files]# mysqladmin -uroot -p password
    [root@test-mysql support-files]# mysql -uroot –p
    mysql> q
    Bye
    


    写作不易,转载请注明出处,谢谢~~

  • 相关阅读:
    养花
    【bzoj1419】Red is good
    C++模板
    逆元求组合数
    【IOI2000】【洛谷1435】回文字串
    Centos 下启动mysql 报错: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)解决方法
    linux系统下进行安装phpMyAdmin(基于Centos)
    达梦数据的安装(Windows10 、linux环境下、麒麟系统下)
    2020-3-3 链表刷题(203. 移除链表元素)
    2020-02-03 刷题
  • 原文地址:https://www.cnblogs.com/ccbloom/p/10731114.html
Copyright © 2020-2023  润新知