centos7安装mysql8压缩包_centos7 mysql8解压版安装

OS:centos 7.3,7.6 64 bit

mem:8G,16g

mysql:mysql-8.0.20-el7-x86_64.tar.gz

安装前请将/etc/selinux/config 改为disabled,否则初始化会报权限的问题

安装之产前的提示:

1、MYSQL表名对大小写敏感,对字段不敏感,并且解压版不像安装版那样,在初始化数据库之前,在my.cnf中

配制lower_case_table_names=1就可以让mysql对表名大小不写敏感。

2、MYSQL的root账号,不能远程登陆了,改成%都没用,不过可以新建一个具有root账号权限的用户来实现管理MYSQL。

3、MYSQL的授权方式变动了,同MYSQL5的变化很大。原来MYSQL5的授权方式失效了。

4、MYSQL的my.cnf中配制default_authentication_plugin=mysql_native_password 否则登录提示caching_sha2_password。

1、解压mysql

tar -xvf mysql-8.0.20-el7-x86_64.tar.gz

2、创建MYSQL用户及组(如果没有安全性要求的话,可以直接使用root用户,省掉很多授权的操作)

groupadd mysql

useradd -s /sbin/nologin -r -g mysql mysql

3、创建数据目录和日志目录

cd /home/software/mysql8

mkdir data

mkdir logs

4、授权mysql用户权限

chgrp -R mysql mysql8/

chown -R mysql mysql8/

chown -R  mysql:mysql /home/software/mysql8/data

chown -R  mysql:mysql /home/software/mysql8/logs

5、进行数据库初始化

如果之前执行过初化了,可以把对应的data目录内容清掉,再执行如下的语句

cd mysql8/bin

./mysqld --initialize --lower-case-table-names=1 --basedir=/home/software/mysql8/ --datadir=/home/software/mysql8/data/ --user=root //root用户权限大,不用授各种文件权限了

如果是CENTOS是英语环境

请使用

./mysqld --initialize --lower-case-table-names=1 --datadir=/root/home/mysql8/data --user=mysql

即不指定basedir 否则会报错

备注:这里的--lower-case-table-names=1 表示查询的时候呼略大小写,同时在my.cny中也配制配制这一项,否则会报错。

//如果出现下面的这样的提示

error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

//那么使用以下命令进行处理

yum remove libnuma.so.1

//记录以下的密码,如果密码现出现>或

//如果密码出现特殊字符:&,$,\等,那需要用\转义

2020-05-21T01:37:57.020274Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

2020-05-21T01:37:57.020388Z 0 [System] [MY-013169] [Server] /home/software/mysql8/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 28465

2020-05-21T01:37:57.029134Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.

2020-05-21T01:37:57.720958Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.

2020-05-21T01:37:59.679346Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: FZkhCmsqA8&_

5、配制mysql

vi /etc/my.cnf

[client]

default-character-set=utf8

socket=/home/software/mysql8/data/mysql.sock

[mysqld]

lower-case-table-names=1

bind-address=172.16.6.36

basedir=/home/software/mysql8

datadir=/home/software/mysql8/data

socket=/home/software/mysql8/data/mysql.sock

max_connections = 1000

innodb_buffer_pool_size=2048M

default_authentication_plugin=mysql_native_password

# 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=/home/software/mysql8/logs/log-error.log

pid-file=/home/software/mysql8/logs/mysql_pid.log

#

# include all files from the config directory

#

!includedir /etc/my.cnf.d

6、建立错误日志

cd /home/software/mysql8/logs

vi log-error.log

7、配制mysql服务

cd /home/software/mysql8/support-files

vi mysql.server

basedir=/home/software/mysql8

datadir=/home/software/mysql8/data

cp mysql.server /etc/init.d/

mv mysql.server mysqld

vi mysqld

basedir=/home/mysql8/

datadir=/home/mysql8/data/

###########指定my.cnf位置,以及用root用户启动(root用户权限大,不用授各种文件权限了)

$bindir/mysqld_safe --defaults-file=/etc/my.cnf --datadir="$datadir" --user=root --pid-file="$mysqld_pid_file_path" $other_args >/dev/null &

chkconfig --add mysqld

chkconfig mysqld on

8、添加防火墙

vi /etc/sysconfig/iptables

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

9、启动mysql

service mysqld start

10、添加环境变量

vi /etc/profile

unset -f pathmunge

export JAVA_HOME=/home/jdk1.8.0_231

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export MYSQL_HOME=/home/software/mysql8

export PATH=${JAVA_HOME}/bin/:${MYSQL_HOME}/bin/:$PATH

source /etc/profile

11.更改mysql的root密码

mysql -uroot -p

输入FZkhCmsqA8\&_

alter user user() identified by 'xxxxxx';

//以下方式无效

#alter user'root'@'%localhost' IDENTIFIED BY 'ypABC@123';

12、创建远程可以访问的root_remote

CREATE USER 'root_remote'@'%' IDENTIFIED BY 'xxxxxx';

grant all privileges on *.* to 'root_remote'@'%'

注意:本文归作者所有,未经作者允许,不得转载

你可能感兴趣的:(centos7安装mysql8压缩包_centos7 mysql8解压版安装)