• Post author:
  • Post category:mysql
  • Post comments:0评论
Like
Like Love Haha Wow Sad Angry

一、获取软件包

  这里我们选择MySQL 社区版5.7.28。MySQL版本分为企业版和社区版, 企业版是收费的,而社区版是开源免费的。
  下载地址:https://downloads.mysql.com/archives/community/

二、安装

1、清理环境
[root@db01 ~]# yum remove -y mariadb-libs

2、创建用户
[root@db01 ~]# useradd mysql

3、创建相关目录并授权
[root@db01 ~]# mkdir -p /mysql/{app,data}
[root@db01 ~]# chown -R mysql.mysql /mysql

4、上传、解压缩、软链接
[root@db01 ~]# tar xf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /mysql/app/
[root@db01 ~]# cd /mysql/app/ && ln -s mysql-5.7.28-linux-glibc2.12-x86_64 mysql && cd

5、设置环境变量
[root@db01 ~]# vim /etc/profile     //末尾添加
export PATH=/mysql/app/mysql/bin:$PATH 

[root@db01 ~]# source /etc/profile

6、安装关键依赖软件包
[root@db01 ~]# yum install -y libaio-devel

7、初始化数据
[root@db01 ~]# mysqld --initialize-insecure --user=mysql --basedir=/mysql/app/mysql --datadir=/mysql/data

  参数介绍:
    --initialize-insecure  不安全初始化,即没有密码。
    --initialize           安全初始化,会自动生成临时密码,4种密码复杂度,12位。
    --user=mysql                 初始化用户
    --basedir=/mysql/app/mysql   软件安装目录
    --datadir=/mysql/data        数据存放位置

  注:5.7和5.6版本初始化命令不一样
   5.7:
    /data/app/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/mysql/app/mysql --datadir=/mysql/data 
   5.6:
    /data/app/mysql/scripts/mysql_install_db --user=mysql --basedir=/mysql/app/mysql --datadir=/mysql/data

8、准备配置文件
[root@db01 ~]# vim /etc/my.cnf
[mysqld]
user=mysql
basedir=/mysql/app/mysql
datadir=/mysql/data
socket=/tmp/mysql.sock

9、启动
[root@db01 ~]# /mysql/app/mysql/support-files/mysql.server start 
Starting MySQL.Logging to '/mysql/data/db01.err'.
 SUCCESS! 
[root@db01 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, 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.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
Like
Like Love Haha Wow Sad Angry

发表评论