美文网首页
离线方式下,Redhat7.2 安装mysql数据库

离线方式下,Redhat7.2 安装mysql数据库

作者: soukou | 来源:发表于2020-03-02 15:25 被阅读0次

1. 软件包:mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz

2. 解压:tar xvf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz

3. 移动到/usr/local/mysq目录下

4. mysql 初始化

./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize

其中: --defaults-file 指定配置文件

--basedir指定Mysql安装目录

--datadir指定数据目录

--user所属用户

执行完毕上述指令会得到一个随机生成密码;

5. 创建数据库用户组和用户:

groupadd mysql

useradd -r -g mysql mysql

6. 创建数据文件夹并赋予相应权限:

mkdir -p /usr/local/mysql/data

chown -R mysql:mysql /usr/local/mysql/data

7. 配置/etc/my.cnf文件

[mysqld]

#bind-address=0.0.0.0

port=3306

user=mysql

#skip-grant-tables

character_set_server=utf8mb4

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data/

socket=/tmp/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions inhttp://fedoraproject.org/wiki/Systemd

[mysqld_safe]

log-error=/usr/local/mysql/data/mysql.err

pid-file=/usr/local/mysql/data/mysql.pid

#

# include all files from the config directory

#

!includedir /etc/my.cnf.d

8. 添加系统服务 

mysql/support-files/mysql.service /etc/init.d/mysqld

9. 启动系统服务

Systemctl enable mysqld 开启服务

Systemctl start mysqld 启动服务

Systemctl status mysqld 查看服务状态

相关文章

网友评论

      本文标题:离线方式下,Redhat7.2 安装mysql数据库

      本文链接:https://www.haomeiwen.com/subject/brfvkhtx.html