UOS系统mysql服务安装
背景
1、安装环境:kvm虚拟机
2、运行环境:uos server-1060e
3、架构:x86
4、安装mysql版本:mysql-5.7
1、安装准备
# Mysql官网
https://downloads.mysql.com/archives/community/
# 下载安装包
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

2、加载mysql安装包
yum -y install mysql57-community-release-el7-10.noarch.rpm

3、安装mysql服务
yum -y install mysql-community-server

4、安装完成后,禁掉GPG检查。(mysql-5.7版本问题)
yum -y install mysql-community-server --nogpgcheck

5、检查服务运行状态
systemctl status mysqld.service

6、安装完成后查看mysql服务默认密码
grep 'password' /var/log/mysqld.log

如果默认密码找不到了,或者忘记登录密码了。可以通过修改配置文件,免密登录。
在配置文件添加:skip-grant-tables
重启mysql服务:systemctl restart mysqld.service
7、登录后修改root用户默认密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
SET PASSWORD对用户"root"@'localhost"没有意义,因为使用的身份验证方法不会将身份验证数据存储在MySQL服务器中。如果要更改身份验证参数,请考虑改用 ALTER USER。

set global validate_password.policy=LOW; 密码策略设置为LOW,表示只验证密码长度,对密码的数字、字母都没要求。
set global validate_password.length=7;密码长度设置为自己想要的长度,表示密码最少有几位。
8、创建新用户并赋予所有权限
# 新建用户
create user 'test'@'%' IDENTIFIED WITH mysql_native_password BY 'new_passwd'
# 赋予权限
grant all privileges on . to '用户名'@'%';
grant all privileges on 指定数据库.* to '用户名'@'%';

9、修改默认配置,允许远程登录。
update user set Host='%' where User='root'; # 注意表头大小写

关注灵活就业新业态,关注公账号:贤才宝(贤才宝https://www.51xcbw.com)