Centos7 安装 mySql 8.0

Scroll Down

centos7 安装 mysql 8

1. 移除 mariadb

rpm -qa | grep mariadb
yum remove mariadb*

2. 安装 mySql

wget https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
yum localinstall mysql80-community-release-el7-3.noarch.rpm
yum install mysql-community-server

3. 配置 my.cnf

# 配置 my.cnf
vim /etc/my.cnf

>>>>>>>

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
init-connect='SET NAMES utf8'
character-set-server=utf8

# 不区分大小写
lower_case_table_names=1
# server接受的数据包大小
max_allowed_packet = 4M

# 默认引擎
default-storage-engine=InnoDB
# 默认使用  mysql_native_password  认证
default_authentication_plugin=mysql_native_password

datadir=/opt/data_mysql
socket=/var/lib/mysql/mysql.sock

# 关闭数据分区储存
symbolic-links=0

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

<<<<<<

4. 启动 mysql 服务

systemctl enable mysqld
systemctl start mysqld

5. 初始化 mysql

# 初始化 mysql
mysqld --initialize --datadir=/opt/data_mysql

6. 重置密码

# 查找 root 初始密码
cat /var/log/mysqld.log

# 设置新的 root 密码,密码不能过于简单,否则不通过
mysql -u root -p
mysql>  ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'P@ssw0rd';

7. 开启远程访问

mysql> use mysql;
mysql> update user set host = '%' where user = 'root';
mysql> FLUSH PRIVILEGES;
鲁ICP备 19052590 号

Copyright © 2020 码动青春

Powered by Halo • Theme by Subtle Galaxy • REFERENCE FROM 寒山

本站运行:

感谢位小伙伴的 次访问

Back to the top