mysql yum安装,密码重置及权限刷新

1,获取安装包
wget http://repo.mysql.com/mysql57-community-release-el7.rpm
或者去官网下载
2,安装
rpm -ivh mysql57-community-release-el7.rpm

3,如果systemctl start mysqld正常启动
#查看初始密码
grep ‘password’ /var/log/mysqld.log |head -n1

#进入mysql,改密并导入数据
mysql -u root -p #输入初始密码登录

#设置密码
set password for root@localhost = password(‘Mysql.123’); #或者
update user set authentication_string=password(‘123456’) where user=‘Mysql.123’;

flush privileges; #刷新权限

#如果密码过于简单,报异常,可修改全局参数
set global validate_password_policy=0;
set global validate_password_length=1;

#数据导入
CREATE DATABASE test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

use test;

根目录下Source,加载sql文件
source /opt/elk/xxx.sql

#允许远程连接
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘Mysql.123’ WITH GRANT OPTION;
flush privileges;

4,如果systemctl start mysqld无法启动
yum install -y mariadb-server

再次启动systemctl start mysqld

mysql -u root -p 忽略密码,直接进入

创建用户名密码
use mysql;
update user set authentication_string=password(‘mysql.8888’) where user=‘root’;

你可能感兴趣的:(数据库)