二进制包离线安装mysql

Posted 程序员超时空

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了二进制包离线安装mysql相关的知识,希望对你有一定的参考价值。

前言

文章目录

本文将介绍离线安装mysql的方式
安装环境:centos7

1. 到官网下载二进制安装包
地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads

2. 创建mysql用户

[root@mysql-server ~]# useradd -r mysql -M -s /bin/false


3. 上传下载好的包,解压缩,创建mysql安装目录,并给予权限.

[root@localhost ~]# ls
mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# tar zxf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost ~]# mv /usr/local/mysql-5.7.32-linux-glibc2.12-x86_64/  /usr/local/mysql
[root@localhost ~]# mkdir /usr/local/mysql/data
[root@localhost ~]# chown -R mysql.mysql /usr/local/mysql/
[root@localhost ~]# ll /usr/local/mysql/
总用量 260
drwxr-xr-x  2 mysql mysql   4096 12月 27 15:04 bin
drwxr-xr-x  2 mysql mysql      6 12月 27 15:06 data
drwxr-xr-x  2 mysql mysql     55 12月 27 15:04 docs
drwxr-xr-x  3 mysql mysql   4096 12月 27 15:04 include
drwxr-xr-x  5 mysql mysql    230 12月 27 15:04 lib
-rw-r--r--  1 mysql mysql 247914 9月  23 20:00 LICENSE
drwxr-xr-x  4 mysql mysql     30 12月 27 15:04 man
-rw-r--r--  1 mysql mysql    587 9月  23 20:00 README
drwxr-xr-x 28 mysql mysql   4096 12月 27 15:04 share
drwxr-xr-x  2 mysql mysql     90 12月 27 15:04 support-files

4. 初始化mysql

[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#初始化用户和安装位置和数据存放位置
2020-12-27T07:08:58.946572Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-12-27T07:08:59.674990Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-12-27T07:08:59.756715Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-12-27T07:08:59.821983Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 6488a347-4812-11eb-9425-000c2907d01b.
2020-12-27T07:08:59.824487Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-12-27T07:09:00.478438Z 0 [Warning] CA certificate ca.pem is self signed.
2020-12-27T07:09:00.650741Z 1 [Note] A temporary password is generated for root@localhost: I#shqhH+(6qk

5. 到etc下配置mysql的配置文件

vim /etc/my.cnf    ---将文件中所有内容注释掉在添加如下内容

[root@youxi1 mysql]# vim /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
socket=/usr/local/mysql/mysql.sock
character-set-server=utf8
log-error=/var/log/mysqld.log
pid-file=/tmp/mysqld.pid
[mysql]
socket=/usr/local/mysql/mysql.sock
[client]
socket=/usr/local/mysql/mysql.sock

6. 配置环境变量,方便管理

vim /etc/profile.d/mysql.sh
最后一行加上这个
export PATH=/usr/local/mysql/bin:$PATH
保存刷新
source /etc/profile.d/mysql.sh
  1. 添加启动脚本 ,并修改密码

    cp support-files/mysql.server /etc/init.d/mysqld

    chmod +x /etc/init.d/mysqld

    vim /etc/init.d/mysqld
    basedir=/usr/local/mysql   #第46行 补全安装目录
    datadir=/usr/local/mysql/data #第47行 补全数据所在目录

    /etc/init.d/mysqld start #刷新

    mysqladmin -u root -p’初始密码’ password ‘新密码’ #新密码必须包含大小写英文、数字、特殊符号。

    #登陆mysql
    mysq -uroot -p’新密码’

以上是关于二进制包离线安装mysql的主要内容,如果未能解决你的问题,请参考以下文章

rpm包离线安装mysql

Visual Studio 2017各版本安装包离线下载安装全解析

ES实战ES 插件包离线安装(本地文件)

Visual Studio 2017各版本安装包离线下载安装全解析

npm 包离线化

npm 包离线化