赞
踩
centos 7 安装 mysql 8 ,安装包直接在mysql官网下载,无需登录
检查防火墙状态
systemctl status firewalld.service
暂时关闭防火墙,下次启动时防火墙仍随系统启动而启动
systemctl stop firewalld.service
彻底永久关闭防火墙
systemctl disable firewalld.service
关闭SELINUX防火墙!
vi /etc/selinux/config
将内容
SELINUX=enforcing
更改为
SELINUX=disabled
查看IP地址 : ifconfig -a / ip a
查看主机名 : hostname
然后修改/etc/hosts文件:
vi /etc/hosts
添加内容:ip 主机名
CENTOS7: rpm -qa |grep mariadb
rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
-
- vim /etc/profile
- export MYSQL_HOME="/usr/local/mysql"
- export PATH="$PATH:$MYSQL_HOME/bin"
- mkdir -p /usr/local/mysql
- mkdir -p /data/mysql_data
- mkdir -p /data/mysql_log
- mkdir -p /data/log_bin
- mkdir -p /data/log_redo
- mkdir -p /data/log_relay
- mkdir -p /data/tmp
- groupadd mysql
- useradd -g mysql mysql
- chown -R mysql.mysql /data/mysql_data /data/mysql_log /data/log_bin /data/log_redo/ /data/log_relay /data/tmp
- chown -R mysql.mysql /usr/local/mysql
将隔离级别修改为读已提交(其它主流数据库默认隔离级别),可以提高并发度。
- [mysqld]
- # GENERAL #
- user = mysql
- collation_server=utf8mb4_general_ci
- character_set_server=utf8mb4
- default_storage_engine = InnoDB
- server_id = 1
- socket = /data/mysql_data/mysql.sock
- pid-file = /data/mysql_data/mysql.pid
- port = 3306
- transaction-isolation = READ-COMMITTED
- lower_case_table_names = 1
- sql_generate_invisible_primary_key = on
-
- # SAFETY #
- max_allowed_packet = 1G
- max_connect_errors = 1000000
- max_connections=3000
- max_user_connections=2800
- open_files_limit=65535
- skip_name_resolve=ON
-
- # DATA STORAGE #
- datadir = /data/mysql_data
- tmpdir = /data/tmp
-
- # BINARY LOGGING #
- binlog-ignore-db=mysql,information_schema,sys,performance_schema
- binlog_format = ROW
- log_bin = /data/log_bin/mysql_bin_3306
- binlog_expire_logs_seconds=1269600
- sync_binlog = 1
- max_binlog_size = 512M
-
- # CACHES AND LIMITS #
- tmp_table_size = 16M
- max_heap_table_size = 32M
- thread_cache_size = 64
- table_definition_cache = 4096
- table_open_cache = 4096
-
- # INNODB #
- #innodb_data_home_dir = /data/mysql_data/ibdata/
- innodb_data_file_path = ibdata1:128M;ibdata2:10M:autoextend
- innodb_flush_method = O_DIRECT
- innodb_lock_wait_timeout = 50
- innodb_flush_log_at_trx_commit = 1
- innodb_file_per_table = ON
- innodb_buffer_pool_instances = 8
- innodb_buffer_pool_size = 8G
-
- # repl #
- #rpl_semi_sync_master_enabled=1
- #rpl_semi_sync_master_timeout=1000
- gtid_mode=on
- enforce-gtid-consistency=1
-
- # REDOLOG #
- innodb_log_group_home_dir = /data/log_redo/
- innodb_log_buffer_size=67108864
- #innodb_log_file_size=256M
- #innodb_log_files_in_group=4
- innodb_redo_log_capacity=20m
-
-
- # LOGGING #
- log_error = /data/mysql_log/mysql_error_3306.log
- log_queries_not_using_indexes=0
- slow_query_log = 1
- long_query_time = 10
- log_slow_admin_statements=1
- slow_query_log_file = /data/mysql_log/mysql_slow_3306.log
-
- # RELAYLOG #
- relay_log = /data/log_relay/relaylog
- relay_log_index = /data/log_relay/relay.index
-
- # SLAVE #
- replica_load_tmpdir=/data/tmp
-
- [client]
- default_character_set=utf8mb4
- socket = /data/mysql_data/mysql.sock
-
- cp -af /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
-
- #############################################
- vi /etc/init.d/mysqld
- 修改两处位置:
- basedir=/usr/local/mysql
- datadir=/data/mysql_data
- #############################################
-
- cd /usr/local/mysql/bin
-
- ./mysqld --initialize --lower-case-table-names=1 --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data
- service mysqld start
-
- mysql -uroot -p --然后这里出现Enter password:的时候直接按回车即可
-
-
- cat /data/mysql_log/mysql_error_3306.log|grep password可以找到初始密码
-
- 登录之后修改初始密码:
- alter user user() identified by '123456';
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。