Linux下安装MySQL

yum install mysql-server

这样自动安装的是Mariadb
如果想坚持安装MySQL(fedaro在21后已经是用dnf代替了yum)

dnf install https://dev.mysql.com/get/mysql57-community-release-fc25-9.noarch.rpm
dnf install mysql-community-server  

重启系统
启动MySQL

systemctl start mysqld.service

设置开机自动启动

systemctl enable mysqld.service

获取生成的随机密码

grep 'A temporary password is generated for root@localhost' /var/log/mysqld.log |tail -1

输出:

Linux下安装MySQL_第1张图片
捕获.PNG

修改密码:

mysqladmin -u root password 123456

报错:

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

不需要mysqld _safe的方法登录
使用之前随机生成的登录之后修改密码

mysql -u root -p
ALTER USER USER() IDENTIFIED BY '123456';

报错:

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

查看得知,原来MySQL5.7增加了密码强度验证插件validate_password,相关参数设置的较为严格

ALTER USER USER() IDENTIFIED BY 'PW93-mysql';

修改成功,exit并用新密码登录

你可能感兴趣的:(Linux下安装MySQL)