安装mysql

Version:

  • CentOS 6.x/7.x/8.x
  • Mysql 5.6/5.7

准备

如果需要,先卸载旧版本mysql

rpm -qa |grep mysql |xargs yum remove -y

CentOS6.x

# Mysql 5.6

// 如果需要,先卸载旧版本mysql
rpm -qa |grep mysql |xargs yum remove -y
// 安装
rpm -ivh https://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
yum install -y mysql-community-client.x86_64 mysql-community-server.x86_64

// 启动配置
service mysqld start
chkconfig mysqld on
mysql_secure_installation

CentOS 7.x

# Mysql 5.6
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
yum install -y mysql-community-server
systemctl enable mysqld
systemctl start mysqld

mysql_secure_installation

# Mysql 5.7
rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum repolist all | grep mysql | grep enabled
yum -y install mysql-community-server

systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld

cat /var/log/mysqld.log | grep -i 'temporary password'
mysql_secure_installation

CentOS 8.x

# Mysql 5.7
# rpm -ivh https://repo.mysql.com//mysql80-community-release-el8-4.noarch.rpm
rpm -ivh http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum -y install yum-utils
yum repolist all | grep mysql | grep enabled
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community

yum -y install mysql-community-server
mysql --version

systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld

cat /var/log/mysqld.log | grep -i 'temporary password'
mysql_secure_installation

一点通用基础配置

vim /etc/my.cnf
# 在[mysqld],[client],[mysql]节点下添加编码设置
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
max_connections=1000
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
default-time_zone='+8:00'

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

QA

How to Fix “Failed to set locale, defaulting to C.UTF-8” in CentOS 8

dnf install -y langpacks-en glibc-all-langpacks glibc-langpack-en
localectl set-locale LANG=en_US.UTF-8
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值