CentOs7 Mysql5.7 安装

下载

wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

安装 mysql 源

yum localinstall mysql57-community-release-el7-11.noarch.rpm

检查 mysql 源是否安装成功,如果没找到需要更新一下软件包yum update

yum repolist enabled | grep "mysql.-community."

安装mysql

yum install -y mysql-community-server

启动mysql

systemctl start mysqld

查询mysql状态

systemctl status mysqld

查看默认的root密码

grep 'temporary password' /var/log/mysqld.log

用默认密码登录后修改密码

mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'guogr@1234#';

重启mysql

systemctl restart mysqld

设置连接编码

set names utf8;

设置全局编码,文件路径/etc/my.cnf

[mysqld]
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8

重启

systemctl restart mysqld

查看编码

show variables like 'character%';

更多

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

你可能感兴趣的:(CentOs7 Mysql5.7 安装)