首页 > 数据库 >Oracle Linux 8 yum 安装 MySQL 8

Oracle Linux 8 yum 安装 MySQL 8

时间:2023-08-25 18:01:54浏览次数:33  
标签:8.0 64 MySQL community 34 innodb mysql Oracle yum

一、安装yum仓库

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el8-8.noarch.rpm

二、先禁用本地的 MySQL 模块

yum module -y disable mysql
MySQL 8.0 Community Server                                                                                                                                                                                                                    273 kB/s | 3.2 MB     00:11    
MySQL Connectors Community                                                                                                                                                                                                                     33 kB/s | 102 kB     00:03    
MySQL Tools Community                                                                                                                                                                                                                          78 kB/s | 794 kB     00:10    
上次元数据过期检查:0:00:01 前,执行于 2023年08月25日 星期五 16时26分33秒。
依赖关系解决。
==============================================================================================================================================================================================================================================================================
 软件包                                                            架构                                                             版本                                                              仓库                                                               大小
==============================================================================================================================================================================================================================================================================
禁用模块:
 mysql                                                                                                                                                                                                                                                                       

事务概要
==============================================================================================================================================================================================================================================================================

完毕!

三、安装最新版的MySQL 8

[root@ol8_mysql101 ~]# yum install mysql-community-server -y
上次元数据过期检查:0:03:32 前,执行于 2023年08月25日 星期五 16时26分33秒。
依赖关系解决。
==============================================================================================================================================================================================================================================================================
 软件包                                                                         架构                                                   版本                                                           仓库                                                               大小
==============================================================================================================================================================================================================================================================================
安装:
 mysql-community-server                                                         x86_64                                                 8.0.34-1.el8                                                   mysql80-community                                                  64 M
安装依赖关系:
 mysql-community-client                                                         x86_64                                                 8.0.34-1.el8                                                   mysql80-community                                                  16 M
 mysql-community-client-plugins                                                 x86_64                                                 8.0.34-1.el8                                                   mysql80-community                                                 3.5 M
 mysql-community-common                                                         x86_64                                                 8.0.34-1.el8                                                   mysql80-community                                                 668 k
 mysql-community-icu-data-files                                                 x86_64                                                 8.0.34-1.el8                                                   mysql80-community                                                 2.2 M
 mysql-community-libs                                                           x86_64                                                 8.0.34-1.el8                                                   mysql80-community                                                 1.5 M

事务概要
==============================================================================================================================================================================================================================================================================
安装  6 软件包

总下载:88 M
安装大小:415 M
下载软件包:
(1/6): mysql-community-common-8.0.34-1.el8.x86_64.rpm                                                                                                                                                                                         114 kB/s | 668 kB     00:05    
(2/6): mysql-community-client-plugins-8.0.34-1.el8.x86_64.rpm                                                                                                                                                                                 579 kB/s | 3.5 MB     00:06    
(3/6): mysql-community-libs-8.0.34-1.el8.x86_64.rpm                                                                                                                                                                                           746 kB/s | 1.5 MB     00:02    
(4/6): mysql-community-icu-data-files-8.0.34-1.el8.x86_64.rpm                                                                                                                                                                                 470 kB/s | 2.2 MB     00:04    
(5/6): mysql-community-client-8.0.34-1.el8.x86_64.rpm                                                                                                                                                                                         987 kB/s |  16 MB     00:16    
(6/6): mysql-community-server-8.0.34-1.el8.x86_64.rpm                                                                                                                                                                                         2.4 MB/s |  64 MB     00:26    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                                                                                                          2.5 MB/s |  88 MB     00:35     
MySQL 8.0 Community Server                                                                                                                                                                                                                    3.0 MB/s | 3.1 kB     00:00    
导入 GPG 公钥 0x3A79BD29:
 Userid: "MySQL Release Engineering <[email protected]>"
 指纹: 859B E8D7 C586 F538 430B 19C2 467B 942D 3A79 BD29
 来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
导入公钥成功
MySQL 8.0 Community Server                                                                                                                                                                                                                    1.9 MB/s | 1.9 kB     00:00    
导入 GPG 公钥 0x5072E1F5:
 Userid: "MySQL Release Engineering <[email protected]>"
 指纹: A4A9 4068 76FC BD3C 4567 70C8 8C71 8D3B 5072 E1F5
 来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                                                                                                                                               1/1 
  安装    : mysql-community-common-8.0.34-1.el8.x86_64                                                                                                                                                                                                                    1/6 
  安装    : mysql-community-client-plugins-8.0.34-1.el8.x86_64                                                                                                                                                                                                            2/6 
  安装    : mysql-community-libs-8.0.34-1.el8.x86_64                                                                                                                                                                                                                      3/6 
  运行脚本: mysql-community-libs-8.0.34-1.el8.x86_64                                                                                                                                                                                                                      3/6 
  安装    : mysql-community-client-8.0.34-1.el8.x86_64                                                                                                                                                                                                                    4/6 
  安装    : mysql-community-icu-data-files-8.0.34-1.el8.x86_64                                                                                                                                                                                                            5/6 
  运行脚本: mysql-community-server-8.0.34-1.el8.x86_64                                                                                                                                                                                                                    6/6 
  安装    : mysql-community-server-8.0.34-1.el8.x86_64                                                                                                                                                                                                                    6/6 
  运行脚本: mysql-community-server-8.0.34-1.el8.x86_64                                                                                                                                                                                                                    6/6 
  验证    : mysql-community-client-8.0.34-1.el8.x86_64                                                                                                                                                                                                                    1/6 
  验证    : mysql-community-client-plugins-8.0.34-1.el8.x86_64                                                                                                                                                                                                            2/6 
  验证    : mysql-community-common-8.0.34-1.el8.x86_64                                                                                                                                                                                                                    3/6 
  验证    : mysql-community-icu-data-files-8.0.34-1.el8.x86_64                                                                                                                                                                                                            4/6 
  验证    : mysql-community-libs-8.0.34-1.el8.x86_64                                                                                                                                                                                                                      5/6 
  验证    : mysql-community-server-8.0.34-1.el8.x86_64                                                                                                                                                                                                                    6/6 

已安装:
  mysql-community-client-8.0.34-1.el8.x86_64         mysql-community-client-plugins-8.0.34-1.el8.x86_64         mysql-community-common-8.0.34-1.el8.x86_64         mysql-community-icu-data-files-8.0.34-1.el8.x86_64         mysql-community-libs-8.0.34-1.el8.x86_64        
  mysql-community-server-8.0.34-1.el8.x86_64        

完毕!

四、创建相应的文件夹

mkdir -p /u01/mysql/data
mkdir -p /u01/mysql/run
mkdir -p /u01/mysql/logs
mkdir -p /u01/mysql/binlog
mkdir -p /u01/mysql/relaylog
chown -R mysql:mysql /u01/mysql

五、修改配置文件 

cat > /etc/my.cnf << EOF
[client]
port	= 3306
socket	= /u01/mysql/run/mysql.sock

[mysql]
prompt = "\u@\h: [\d]> "
no_auto_rehash
loose-skip-binary-as-hex

[mysqld]
user	= mysql
port	= 3306
server_id = 1

#all dir file
basedir = /usr/local/mysql
datadir	= /u01/mysql/data
socket	= /u01/mysql/run/mysql.sock
slow_query_log_file = /u01/mysql/logs/slow.log
log_error = /u01/mysql/logs/error.log
log_bin = /u01/mysql/binlog/mybinlog
relay_log = /u01/mysql/relaylog

pid_file = mysqldb.pid
character_set_server = UTF8MB4
skip_name_resolve = 1
default_time_zone = "+8:00"
admin_address = '127.0.0.1'
admin_port = 33062
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
character-set-server=utf8mb4
autocommit = 1
innodb_file_per_table=1


#performance setttings
lock_wait_timeout = 3600
open_files_limit    = 65535
back_log = 1024
max_connections = 812
max_connect_errors = 1000000
table_open_cache = 1024
table_definition_cache = 1024
thread_stack = 512K
sort_buffer_size = 16M
join_buffer_size = 16M
read_buffer_size = 8M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
thread_cache_size = 1218
interactive_timeout = 600
wait_timeout = 600
tmp_table_size = 96M
max_heap_table_size = 96M

#log settings
log_timestamps = SYSTEM
log_error_verbosity = 3
slow_query_log = 1
log_slow_extra = 1
long_query_time = 0.1
log_queries_not_using_indexes = 1
log_throttle_queries_not_using_indexes = 60
min_examined_row_limit = 100
log_slow_admin_statements = 1
log_slow_slave_statements = 1

binlog_format = ROW
sync_binlog = 10
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
binlog_rows_query_log_events = 1
binlog_expire_logs_seconds = 2592000
binlog_checksum = CRC32
gtid_mode = ON
enforce_gtid_consistency = TRUE

#myisam settings
key_buffer_size = 32M
myisam_sort_buffer_size = 128M

#replication settings
relay_log_recovery = 1
slave_parallel_type = LOGICAL_CLOCK
slave_parallel_workers = 4 
binlog_transaction_dependency_tracking = WRITESET
slave_preserve_commit_order = 1
slave_checkpoint_period = 2
replication_optimize_for_static_plugin_config = ON
replication_sender_observe_commit_only = ON

# async replication settings
skip_slave_start

#innodb settings
#transaction_isolation = REPEATABLE-READ
transaction_isolation = READ-COMMITTED
innodb_buffer_pool_size = 5G
innodb_buffer_pool_instances = 4
innodb_data_file_path = ibdata1:12M:autoextend
innodb_flush_log_at_trx_commit = 1 
innodb_log_buffer_size = 32M
innodb_log_file_size = 1G 
innodb_log_files_in_group = 3
loose-innodb_redo_log_capacity = 3G
innodb_max_undo_log_size = 4G
innodb_io_capacity = 14000
innodb_io_capacity_max = 28000
innodb_open_files = 65535
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth = 4000
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_online_alter_log_max_size = 4G
innodb_print_ddl_logs = 1
innodb_status_file = 1
#注意: 开启 innodb_status_output & innodb_status_output_locks 后, 可能会导致log_error文件增长较快
innodb_status_output = 0
innodb_status_output_locks = 1
innodb_sort_buffer_size = 67108864
innodb_adaptive_hash_index = OFF
#提高索引统计信息精确度
innodb_stats_persistent_sample_pages = 500
innodb_adaptive_hash_index = 0
loose-sql_generate_invisible_primary_key = ON

#innodb monitor settings
innodb_monitor_enable = "module_innodb"
innodb_monitor_enable = "module_server"
innodb_monitor_enable = "module_dml"
innodb_monitor_enable = "module_ddl"
innodb_monitor_enable = "module_trx"
innodb_monitor_enable = "module_os"
innodb_monitor_enable = "module_purge"
innodb_monitor_enable = "module_log"
innodb_monitor_enable = "module_lock"
innodb_monitor_enable = "module_buffer"
innodb_monitor_enable = "module_index"
innodb_monitor_enable = "module_ibuf_system"
innodb_monitor_enable = "module_buffer_page"
#innodb_monitor_enable = "module_adaptive_hash"

#pfs settings
performance_schema = 1
#performance_schema_instrument = '%memory%=on'
loose-performance_schema_instrument = '%lock%=on'

[mysqldump]
quick

EOF

六、关闭selinux和防火墙,并启动mysql

[root@ol8_mysql101 /]# /sbin/setenforce 0
[root@ol8_mysql101 /]# sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
[root@ol8_mysql101 /]# systemctl stop firewalld.service 
[root@ol8_mysql101 /]# systemctl disable firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@ol8_mysql101 /]# systemctl start  mysqld.service

七、修改密码

[root@ol8_mysql101 /]# cat /u01/mysql/logs/error.log |grep "password is generated"
2023-08-25T17:23:07.229407+08:00 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: yhg7e&C*U4jw
[root@ol8_mysql101 /]# mysql -uroot -p"yhg7e&C*U4jw"
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.34

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@mysqldb 17:29:  [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.02 sec)

root@mysqldb 17:30:  [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

八、系统添加免密登陆

[root@ol8_mysql101 /]# cat > ~/.my.cnf <<EOF
[client]
user = root
password = 123456
EOF

[root@ol8_mysql101 /]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.34 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@mysqldb 17:34:  [(none)]>

标签:8.0,64,MySQL,community,34,innodb,mysql,Oracle,yum
From: https://blog.51cto.com/mydbs/7233740

相关文章

  • mysql 常用脚本语法
    mysql常用脚本语法创建表:CREATETABLEtest_db1.test_table1(idINTauto_incrementNOTNULL,my_namevarchar(100)NOTNULL,memovarchar(100)NULL,CONSTRAINTtest_table1_PKPRIMARYKEY(id))ENGINE=InnoDBDEFAULTCHARSET=utf8mb4COLLATE=ut......
  • 【MySQL 8.0】通过Clone Plugin实现数据库的复制
    (root@node01)>createuser'donor'@'%'identifiedby'donor';QueryOK,0rowsaffected(0.10sec)(root@node01)>grantbackup_adminon*.*to'donor'@'%';QueryOK,0rowsaffected(0.23sec)(r......
  • mysql联合更新
    updaterailwayrjoinrailway_sectionrsonr.id=rs.railway_idjoinwork_stationwsonr.id=ws.railway_idjoinpatrollerponr.id=p.railway_idsetrs.railway_name=#{name},ws.railway_name=#{na......
  • 【MySQL 8.0】通过mysqlpump实现数据库对象的逻辑备份与恢复
    转储数据库mysqlpump-uroot-p--all-databases>full.sqlmysqlpump-uroot-p--all-databases--exclude-databases=soe>full.sqlmysqlpump-uroot-p--databasestpcc10>tpcc10.sqlmysqlpump-uroot-p--parallel-schemas=4:tpcc10>tpcc10.sql......
  • Linux安装oracle23c
    官网下载:1.rpm包oracle-database-free-23c-1.0-1.el8.x86_64.rpmoracle-database-preinstall-23c-1.0-0.5.el8.x86_64.rpm2.安装依赖包上传compat-openssl10-1.0.2u-1.el9.x86_64.rpm包并且进行安装此依赖包需要先进行安装rpm-ivhcompat-openssl10-1.0.2u-1.el9......
  • CentOS/RedHat下RPM方式安装MySQL 5.7
    摘要本文详细记录了Linux下MySQL5.7的安装步骤,基于CentOS7.2与中标麒麟7两个版本的操作系统下的实践总结而成(大多数图片截取自中标麒麟7)。引子我所在的人力资源和社会保障行业线,项目的业务数据库绝大多数是Oracle,其实很少见到MySQL。近几年有从Oracle向国产数据库(OceanBase、达......
  • 【MySQL 8.0】通过mysqlbinlog实现binlog文件的远程同步
    mysqlbinlog会伪装成一个slave,连接master请求指定的binlogfile,master接收到这个请求之后创建一个binlogdump线程推送binlog给伪装的slave。[mysql@node01~]$mysql-uroot-pabcd.1234-hnode01(root@node01)>createuserrepl@'%'identifiedby'repl';QueryOK,0ro......
  • nacos适配SqlServer、Oracle
    继上文《nacos适配达梦、瀚高、人大金仓数据库及部分源码探究 》后补充nacos适配SqlServer、Oracle的贴码,主要区别是SqlServer、Oracle的分页SQL有点不一样,做个记录;SqlServer的分页有三种实现方式:offset/fetchnext、利用max(主键)、利用row_number关键字;ps:具体可参......
  • 【MySQL 8.0】部分备份与恢复验证
    [mysql@node01~]$xtrabackup--user=xtrabackup--password=xtrabackup--databases="tpcc10"--backup--target-dir=/home/mysql/backup/partial[mysql@node01~]$scp-rbackup/partial/*node02:/home/mysql/backup/partial[mysql@node01~]$mysqldump......
  • 【MySQL 8.0】物理备份与恢复验证
    [root@node01~]#wgethttps://repo.percona.com/yum/percona-release-latest.noarch.rpm[root@node01~]#rpm-ivhpercona-release-latest.noarch.rpm[root@node01~]#yuminstall-ypercona-xtrabackup-80用户与权限(root@node01)>createuserxtrabackup@'......