您现在的位置是:今夕何夕> LINUX 文章详情

Centos 7.6安装MYSQL

久伴轻尘 2019-08-06 22:36 LINUX 0人已浏览

1:在 usr/local 目录中创建 mysql文件夹
mkdir mysql
cd mysql​
2:下载源到服务器
wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm​
3:安装下载的发行包(源)
rpm -Uvh mysql80-community-release-el7-1.noarch.rpm​
4:安装mysql
yum install mysql-community-server​
5:启动MySql
service mysqld start​
6:查看Mysql密码
grep 'temporary password' /var/log/mysqld.log​
7:登录mysql及配置
##登录mysql
mysql -u root -p (你的密码)

##修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Abc.123!';

##查看密码策略
show variables like '%password%';

##设置密码安全等级为最低,密码长度为6
set global validate_password.policy=LOW;
set global validate_password.length=6;​
8:创建MYSQL远程连接配置(配置root用户)
CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
FLUSH PRIVILEGES;​
9:修改密码策略
ALTER USER 'root'@'%'IDENTIFIED WITH (策略类型)  BY '123456';​
10:给root用户最高权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';