编程知识 cdmana.com

CentOS8下MySQL8的安装(在线版)

[TOC]

MySQL安装

移除旧版

  • 检查系统已安装的MySQL/MariaDB
rpm -qa |grep mysql
rpm -qa |grep mariadb
  • 移除已安装的mariadb组件
rpm -ev --nodeps mariadb-libs

下载MySQL

cd /tmp
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.20-1.el8.x86_64.rpm-bundle.tar
tar -xvf mysql-8.0.20-1.el8.x86_64.rpm-bundle.tar

安装MySQL

rpm -ivh mysql-community-common-8.0.20-1.el8.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.20-1.el8.x86_64.rpm
rpm -ivh mysql-community-client-8.0.20-1.el8.x86_64.rpm
rpm -ivh mysql-community-server-8.0.20-1.el8.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.20-1.el8.x86_64.rpm

修改my.cnf

此处一定要先修改my.cnf,才能在首次启动服务(初始化)的时候,使用上参数lower_case_table_names

vi /etc/my.cnf
  • 追加内容如下
############################################################################

lower_case_table_names=1
default_authentication_plugin=mysql_native_password
default-time_zone = '+8:00'
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character-set-server = utf8mb4

performance_schema_max_table_instances = 600
table_definition_cache = 400
table_open_cache = 256

[mysql]
default-character-set = utf8mb4

[client]
default-character-set = utf8mb4

############################################################################

启动MySQL服务

  • 启动服务,同时初始化数据库
systemctl start mysqld.service
  • 查看临时密码
grep 'temporary password' /var/log/mysqld.log

2020-05-13T05:04:30.405961Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ########

更新root密码并新建用户

root本地账户

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '********' PASSWORD EXPIRE NEVER;

dba本地账户

DROP USER 'dba'@'localhost';
CREATE USER 'dba'@'localhost' IDENTIFIED BY '********' PASSWORD EXPIRE NEVER;
GRANT ALL PRIVILEGES ON *.* TO 'dba'@'localhost';
FLUSH PRIVILEGES;

dba远程账户

DROP USER 'dba'@'%';
CREATE USER 'dba'@'%' IDENTIFIED BY '********' PASSWORD EXPIRE NEVER;
GRANT ALL PRIVILEGES ON *.* TO 'dba'@'%';
FLUSH PRIVILEGES;

版权声明
本文为[静风流云]所创,转载请带上原文链接,感谢
https://my.oschina.net/rox/blog/4711331

Scroll to Top