【运维笔记】centos安装mysql8

下载mysql源安装包

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

安装mysql源

 yum -y localinstall  mysql57-community-release-el7-10.noarch.rpm

安装MySQL

yum -y install mysql-community-server

启动MySQL服务

systemctl start mysqld

查看MySQL的启动状态

systemctl status mysqld.service

开机启动

systemctl enable mysqld
systemctl daemon-reload

查看mysql初始默认密码

grep "password" /var/log/mysqld.log

连接mysql数据库

mysql -uroot -p初始默认密码

重新设置密码

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root123';  简单的密码会重置密码失败

调整密码验证规则

MySQL 5.7 MySQL 8.0
set global validate_password_policy=0; set global validate_password.policy=0;
set global validate_password_length=1; set global validate_password.length=1;

 修改/etc/my.cnf配置文件

[mysqld]

character_set_server=utf8

init_connect='SET NAMES utf8'

port=3306

重新启动mysql服务使配置生效

systemctl restart mysqld

进行远程访问的授权

 create user 'root'@'%' identified with mysql_native_password by 'root123';

grant all privileges on *.* to 'root'@'%' with grant option;

flush privileges;

修改端口号、开放端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent

firewall-cmd --reload

默认配置文件路径

配置文件:     /etc/my.cnf 
日志文件:    /var/log//var/log/mysqld.log 
服务启动脚本:   /usr/lib/systemd/system/mysqld.service 
socket文件:      /var/run/mysqld/mysqld.pid

你可能感兴趣的:(运维笔记)