CentOS-7 二进制安装mysql5.7.31

1、环境准备

  虚拟机:centos 7 ip:192.168.137.128

  mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz   https://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz

2、开始安装

  添加mysql用户

  useradd mysql -s /sbin/nologin

  CentOS-7 二进制安装mysql5.7.31

 

  解压mysql二进制包并重命名

  tar -zxf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz

  mv mysql-5.7.31-linux-glibc2.12-x86_64 mysql

  CentOS-7 二进制安装mysql5.7.31

  新建mysql 数据存储目录data,以及创建my.cnf配置文件

  CentOS-7 二进制安装mysql5.7.31

  my.cnf配置文件参考

[mysql]
port=3306
socket=/usr/local/mysql/mysql.sock
default-character-set=utf8

[mysqld_safe]
log-error=/usr/local/mysql/data/mysql.error

[mysqld]
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
pid-file=/usr/local/mysql/mysql.pid
character-set-server=utf8
skip-name-resolve
lower_case_table_names=1
query_cache_size=0
transaction_isolation=READ-COMMITTED
tmp_table_size=128M
max_heap_table_size=96M
max_connections=1000
max_connect_errors=6000
long_query_time=1
innodb_buffer_pool_size=2G
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=8M
innodb_log_file_size=128M
innodb_log_files_in_group=2
innodb_file_per_table=1
innodb_flush_method=O_DIRECT
innodb_file_format=Barracuda
innodb_write_io_threads=8
innodb_read_io_threads=4
innodb_doublewrite=0
innodb_purge_threads=1
innodb_stats_on_metadata=OFF
innodb_io_capacity=1000
log-bin-trust-function-creators=1
event_scheduler=on

  初始化数据库

   修改mysql目录的属主和属组

  chown mysql:mysql mysql -R

  CentOS-7 二进制安装mysql5.7.31

   初始化数据库

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

  CentOS-7 二进制安装mysql5.7.31

  记录mysql初始化临时密码

   CentOS-7 二进制安装mysql5.7.31

   修改mysql目录下support-files目录中的mysql.server文件

  修改basedir和datadir

  CentOS-7 二进制安装mysql5.7.31

  CentOS-7 二进制安装mysql5.7.31

   启动mysql服务

  ./mysql.server start

  CentOS-7 二进制安装mysql5.7.31

   使用mysql临时随机密码登录数据库修改root密码,密码为强制修改,否则无法正常使用

  ./mysql -S/usr/local/mysql/mysql.sock -uroot -p

  CentOS-7 二进制安装mysql5.7.31

  修改密码

  ALTER USER USER() IDENTIFIED BY ‘密码‘;

  flush privileges;       # 刷新mysql表授权

  CentOS-7 二进制安装mysql5.7.31

 

 到此,mysql二进制安装完成!

CentOS-7 二进制安装mysql5.7.31

 

CentOS-7 二进制安装mysql5.7.31

上一篇:CSS中盒子模型和position(一)


下一篇:HTML相对路径和绝对路径