CentOS 7.4 RPM安装Mysql8

一 系统配置

1 安装依赖包

yum -y install wget  cmake gcc gcc-c++ ncurses  ncurses-devel  libaio-devel  openssl openssl-devel perl net-tools

2 关闭SELinux和防火墙

systemctl stop firewalld 
systemctl disable firewalld 
vi /etc/selinux/config
SELINUX=disabled

在这里插入图片描述
重启电脑

二 卸载mariadb

rpm -qa | grep mariadb

在这里插入图片描述
有几个卸载几个

yum -y remove mariadb-libs-5.5.56-2.el7.x86_64

三 安装Mysql

tar -xvf mysql-8.0.12-1.el7.x86_64.rpm-bundle.tar
rpm -ivh --force mysql-community-common-8.0.12-1.el7.x86_64.rpm
rpm -ivh --force mysql-community-libs-8.0.12-1.el7.x86_64.rpm
rpm -ivh --force mysql-community-libs-compat-8.0.12-1.el7.x86_64.rpm
rpm -ivh --force mysql-community-devel-8.0.12-1.el7.x86_64.rpm
rpm -ivh --force mysql-community-client-8.0.12-1.el7.x86_64.rpm
rpm -ivh --force mysql-community-server-8.0.12-1.el7.x86_64.rpm

四 启动Mysql服务

1 创建文件夹

mkdir -p /app/mysql/mysqldata/{3306/{data,tmp,binlog,innodb_ts,innodb_log,undo},backup,scripts}
chown -R mysql:mysql /app/mysql/

2 修改配置文件

echo '' > /etc/my.cnf
vi /etc/my.cnf


[client]
port = 3306
socket = /app/mysql/mysqldata/3306/mysql.sock
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld_multi]  
mysqld = /usr/bin/mysqld_safe  
mysqladmin = /usr/bin/mysqladmin  
log = /app/mysql/mysqldata/mysqld_multi.log  


[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
default-authentication-plugin=mysql_native_password
port = 3306
mysqlx_port = 33060
user = mysql
socket = /app/mysql/mysqldata/3306/mysql.sock
mysqlx_socket=/app/mysql/mysqldata/3306/mysqlx.sock
pid-file = /app/mysql/mysqldata/3306/mysql.pid
datadir = /app/mysql/mysqldata/3306/data
tmpdir = /app/mysql/mysqldata/3306/tmp
open_files_limit = 60000
explicit_defaults_for_timestamp
server-id = 10054
lower_case_table_names = 1
character-set-server = utf8mb4
federated
#sql_mode=STRICT_TRANS_TABLES
max_connections = 1000
max_connect_errors = 100000
interactive_timeout = 86400
wait_timeout = 86400
back_log=100
default-storage-engine = InnoDB
#*********** GTID settting*******************
log_slave_updates = 1
gtid_mode=ON
enforce-gtid-consistency=true
innodb_flush_log_at_trx_commit=2
binlog_format= row
skip-slave-start=1
sync_binlog=5
#*********** Logs related settings ***********
log-bin = /app/mysql/mysqldata/3306/binlog/mysql-bin
binlog_cache_size=32m
max_binlog_cache_size=64m
max_binlog_size=512m
long_query_time = 1
log_output = FILE
log-error = /app/mysql/mysqldata/3306/mysql-error.log
slow_query_log = 1
slow_query_log_file = /app/mysql/mysqldata/3306/slow_statement.log
#log_queries_not_using_indexes
general_log = 0
general_log_file = /app/mysql/mysqldata/3306/general_statement.log
#expire-logs-days = 14
binlog_expire_logs_seconds = 1728000
relay-log = /app/mysql/mysqldata/3306/binlog/relay-bin
relay-log-index = /app/mysql/mysqldata/3306/binlog/relay-bin.index
#****** MySQL Replication New Feature********* 
master-info-repository=TABLE
relay-log-info-repository=TABLE
relay-log-recovery
#*********** INNODB Specific options *********** 
innodb_buffer_pool_size = 10G
transaction-isolation=REPEATABLE-READ
innodb_buffer_pool_instances = 8
innodb_file_per_table = 1
innodb_data_home_dir = /app/mysql/mysqldata/3306/innodb_ts
innodb_data_file_path = /app/mysql/mysqldata/3306/innodb_ts/ibdata1:2048M:autoextend
innodb_thread_concurrency = 8
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 4
innodb_undo_tablespaces=3
innodb_undo_directory =/app/mysql/mysqldata/3306/undo
innodb_log_group_home_dir = /app/mysql/mysqldata/3306/innodb_log
innodb_flush_log_at_trx_commit = 2
innodb_max_dirty_pages_pct = 70
innodb_flush_method=O_DIRECT
innodb_open_files=63000
innodb_rollback_on_timeout=ON
innodb_deadlock_detect=ON

[mysql]
no-auto-rehash
default-character-set=utf8mb4
prompt = (\u@\h) [\d]>\_

3 启动服务

service mysqld restart

4 配置Mysql

4.1 修改密码

vi /app/mysql/mysqldata/3306/mysql-error.log 

在这里插入图片描述

mysql -uroot -p

输入上图密码
在这里插入图片描述

4.2 重置密码

alter user user() identified by "root";
use mysql;
update user set authentication_string = '' where user = 'root';
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
update user set host = '%' where user = 'root';
flush privileges;

若重置密码报错

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
执行如下SQL

set global validate_password.policy=0;
set global validate_password.length=4;
set global validate_password.check_user_name=OFF;
set global validate_password.number_count=0;
set global validate_password.special_char_count=0;
flush privileges;
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值