Linux(2)—— Centos7下单机版Mysql5.7安装

下载并安装源

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

Linux(2)—— Centos7下单机版Mysql5.7安装

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

Linux(2)—— Centos7下单机版Mysql5.7安装

安装并启动Mysql-server

yum -y install mysql-server

Linux(2)—— Centos7下单机版Mysql5.7安装

systemctl start mysqld

修改Mysql密码

查看默认密码

grep ‘temporary password’ /var/log/mysqld.log

Linux(2)—— Centos7下单机版Mysql5.7安装

修改密码

ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘[email protected]’;

Linux(2)—— Centos7下单机版Mysql5.7安装

简单扩展

授权远程登陆(授权所有人以root用户登录)

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘[email protected]’ WITH GRANT OPTION;

Linux(2)—— Centos7下单机版Mysql5.7安装

如果不想以root用户登录,可以输入以下SQL

GRANT ALL PRIVILEGES ON . TO ‘YOURUSER’@’%’ IDENTIFIED BY ‘[email protected]’ WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON . TO ‘YOURUSER’@‘localhost’ IDENTIFIED BY ‘[email protected]’ WITH GRANT OPTION;

设置Mysql5.7编码格式为utf8

查看编码格式

show variables like ‘character_set_%’;

Linux(2)—— Centos7下单机版Mysql5.7安装

关闭数据库

systemctl stop mysqld

修改配置文件/etc/my.cnf,在[mysqld]选项下添加:

character_set_server=utf8

重启数据库

systemctl restart mysqld

查看编码格式

racter_set_server=utf8

重启数据库

systemctl restart mysqld

查看编码格式

Linux(2)—— Centos7下单机版Mysql5.7安装

如有不妥,敬请指正~