Mysql 安装及配置

Tags
软件
运维
Published
Published January 1, 2023
Property

安装

下载rpm 版本,可以官网找版本
//如果wget提示找不到命令,则安装 sudo yum install wget wget <https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm> # 安装软件包源 sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm # 安装mysql sudo yum install mysql-server # 启动 sudo systemctl start mysqld # 查看状态 sudo systemctl status mysqld

配置

# 查看临时密码 sudo grep 'temporary password' /var/log/mysqld.log # 登录 mysql -u root -p # 设置新密码 ALTER USER root@localhost IDENTIFIED BY '123456'; # 配置权限 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; # 刷新权限 flush privileges;

问题

1、You must reset your password using ALTER USER statement before executing this statement
alter user user() identified by "你要设置的新密码";
2、Your password does not satisfy the current policy requirements
set global validate_password_policy=LOW; set global validate_password_length=6;
3、is not allowed to connect to this mysql server 本地无法远程连接
mysql -u root -p use mysql; select host from user where user='root'; update user set host = '%' where user ='root'; flush privileges;