Mysql5.7.19在Centos7下安装教程详解

这篇文章主要介绍了centos7 下mysql5.7.19安装教程详解,小编认为非常不错,特此分享到脚本之家平台,需要的朋友参考下吧

1、下载

从官网下载mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz,版本为5.7.19

下载地址:

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gzLinux

2、创建mysql用户组及用户

l  创建mysql用户组

#groupadd mysql

l  在mysql用户组下创建mysql用户

#useradd mysql -g mysql

3、确定安装目录和数据目录

我的mysql安装目录为/data/mysql,数据目录为/data/mysql/data。

4、上传安装文件到服务器

把mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz文件通过ftp工具放到/data/installfiles目录.

5、解压tar.gz文件/data目录

#cd /data/installfiles  #tar -xvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

6、修改目录名

将mysql-5.7.19-linux-glibc2.12-x86_64更名为mysql并移动到 /usr/local/mysql下。

#mv mysql-5.7.19-linux-glibc2.12-x86_64 /data/mysql

7、创建存放数据目录

在/data /mysql下创建data目录

#mkdir /data/mysql/data

8、对mysql用户进行授权

 将mysql目录及下面的文件、子目录文件主改成mysql

#cd /data  #chown -R mysql:mysql mysql/

给与mysql目录及下面的文件、子目录755权限

#chmod -R 755 mysql/

9、编译安装并初始化mysql,并记住临时密码

#/data/mysql/bin/mysqld --initialize --user=mysql --datadir=/data/mysql/data --basedir=/data/mysql

当时安装的临时密码为:root@localhost:3?2YBeSg:Nte 

10、创建日志文件目录

mkdir -p /data/mysql/log/mariadb/  cd /data/mysql/log/mariadb/  touch mariadb.log  chmod -R 775 mariadb.log  chown -R mysql:mysql mariadb.log  chown -R mysql:mysql /data/mysql

11、启动mysql服务

/data/mysql/support-files/mysql.server start

12、登录msyql,输入密码(密码为第9步骤的初始化密码)

#mysql -u root -p

13、 修改密码为“123456”

msql>alter user 'root'@'localhost' identified by '123456';  mysql>use mysql;  msyql>update user set user.Host='%' where user.User='root';  mysql>flush privileges;  mysql>quit

14、修改/etc/my.cnf文件

# instructions in http://fedoraproject.org/wiki/Systemd  socket=/tmp/mysql.sock  [mysqld]  datadir=/data/mysql/data  socket=/tmp/mysql.sock  max_connections=1000  # 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 in http://fedoraproject.org/wiki/Systemd  [mysqld_safe]  log-error=/data/mysql/log/mariadb/mariadb.log  pid-file=/data/mysql/run/mariadb/mariadb.pid  #  # include all files from the config Directory  #  !includedir /etc/my.cnf.d

修改标红部分内容。

总结

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享