centos安装mysql
文章创建于 2018-07-23 05:28:51

配置YUM源

下载mysql源安装包

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

安装mysql源

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

检查mysql源是否安装成功

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

安装MySQL

yum install mysql-community-server

启动MySQL服务

systemctl start mysqld

开机启动

systemctl enable mysqld
systemctl daemon-reload

root密码

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

root用户远程登录

检查root配置

# root用户登录
mysql -u root -p

# 切换到mysql这个数据库
use mysql;

# 查看root用户配置
select host,user from user where user='root';

修改root配置

update user set host = '%' where user = 'root' and host = '127.0.0.1';

给用户授权

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

使配置生效

flush privileges;
本文链接