MySQL部署

1、卸载mariadb

rpm -qi mariadb-libs

yum remove mysql-libs -y

2、查看操作系统内核版本及硬件架构

uname -a

3、查看glibc版本

ldd --version

4、下载mysql压缩包

wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.35-linux-glibc2.17-x86_64.tar

5、解压到/mnt目录

yum install -y tar

tar -xvf mysql-8.0.35-linux-glibc2.17-x86_64.tar -C /usr/local

cd /usr/local

tar -xf mysql-8.0.35-linux-glibc2.17-x86_64.tar.xz

mv mysql-8.0.35-linux-glibc2.17-x86_64 mysql

6、创建数据目录

mkdir -p /mnt/data/mysql8_data/mysql

7、创建用户组、用户及授权

groupadd mysql

useradd -g mysql mysql

chown -R mysql.mysql /usr/local/mysql

chown -R mysql.mysql /mnt/data/mysql8_data

8、创建my.cnf文件

touch /etc/my.cnf

For advice on how to change settings please see

http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

mysqld

port=13306

sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'

server_id=100

binlog-ignore-db=sys

binlog-ignore-db=information_schema

binlog-ignore-db=performance_schema

binlog-ignore-db=mysql

binlog_cache_size=1M

binlog_format=mixed

expire_logs_days=7

slave_skip_errors=1062

datadir=/mnt/data/mysql8_data/mysql

log-bin=/mnt/data/mysql8_data/log-bin

socket=/usr/local/mysql/mysql.sock

log-error=/mnt/data/mysql8_data/mysqld.log

pid-file=/mnt/data/mysql8_data/mysqld.pid

character-set-server=utf8mb4

lower_case_table_names=1

autocommit =1

skip-external-locking

key_buffer_size = 256M

max_allowed_packet = 100M

table_open_cache = 1024

sort_buffer_size = 4M

net_buffer_length = 8K

read_buffer_size = 4M

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 64M

thread_cache_size = 128

tmp_table_size = 128M

explicit_defaults_for_timestamp = true

max_connections = 500

max_connect_errors = 100

open_files_limit = 65535

binlog_format=mixed

binlog_expire_logs_seconds =864000

default_storage_engine = InnoDB

innodb_data_file_path = ibdata1:10M:autoextend

innodb_buffer_pool_size = 1024M

innodb_log_file_size = 256M

innodb_log_buffer_size = 8M

innodb_flush_log_at_trx_commit = 1

innodb_lock_wait_timeout = 50

transaction-isolation=READ-COMMITTED

mysqldump

quick

max_allowed_packet = 16M

myisamchk

key_buffer_size = 256M

sort_buffer_size = 4M

read_buffer = 2M

write_buffer = 2M

mysqlhotcopy

interactive-timeout=2880000

wait_timeout=2880000

9、 初始化基础信息得到临时密码

cd /usr/local/mysql/bin

./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/mnt/data/mysql8_data/mysql/ --initialize

vi /mnt/data/mysql8_data/mysqld.log

10、 添加mysqld服务到系统

cd /usr/local/mysql

cp -a ./support-files/mysql.server /etc/init.d/mysql

chmod +x /etc/init.d/mysql

chkconfig --add mysql

service mysql start

service mysql status

11、 将mysql命令添加到系统指令

ln -s /usr/local/mysql/bin/mysql /usr/bin

ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock

12、 登录mysql,密码使用之前随机生成的密码

mysql -uroot -p

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'ron999';

flush privileges;

use mysql;

update user set host='%' where user='root';

flush privileges;

相关推荐
重生之绝世牛码3 分钟前
Linux软件安装 —— zookeeper集群安装
大数据·linux·运维·服务器·zookeeper·软件安装
额12915 分钟前
磁盘物理卷、卷组、逻辑卷管理
linux·运维·服务器
Maggie_ssss_supp15 分钟前
Linux-正则表达式
linux·运维·正则表达式
是娇娇公主~17 分钟前
C++集群聊天服务器(3)—— 项目数据库以及表的设计
服务器·数据库·c++
重生之绝世牛码24 分钟前
Linux软件安装 —— kafka集群安装(SASL密码验证)
大数据·linux·运维·服务器·分布式·kafka·软件安装
努力的小帅30 分钟前
Linux_多线程(Linux入门到精通)
linux·多线程·多进程·线程同步·线程互斥·生产消费者模型
晴天¥32 分钟前
操作系统由MBR->GPT,导致系统黑屏是怎么回事?
linux
w***765536 分钟前
临时文件自动化管理:高效安全新方案
运维·安全·自动化
Volunteer Technology42 分钟前
Nginx部署静态项目
运维·服务器·nginx