mysql 启动加上user,MYSQL-5.7

1、yum安装

1)卸载mariadb

rpm -qa | grep mariadb | xargs rpm -e --nodeps

2)下载msql5.7 yum源

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

3)安装yum源

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

4)安装mysql

yum -y install mysql-server

5)启动mysql

service mysqld start

6)查看root用户密码

grep 'temporary password' /var/log/mysqld.log

7)执行mysql初始化脚本

mysql_secure_installation

8)输入新密码(至少12个字符,至少包含一个大写字母有,一个小写字母,一个数字,一个特殊字符)

e2587222182836b7e26c179b300788e2.png

9)配置root用户远程访问权限

mysql> grant all privileges on *.* to 'root' @'%' identified by '@123456Qa';

mysql> flush privileges;

10)安装mysql驱动

(1)将mysql-connector-java-5.1.27-bin.jar拷贝到/usr/share/java路径下,并重命名

mv mysql-connector-java-5.1.27-bin.jar mysql-connector-java.jar

(2)分发驱动

xsync /usr/share/java

2、rpm安装

卸载mariadb

rpm -qa | grep mariadb | xargs rpm -e --nodeps

导入rpm包

检查

必须有如下两个包

rpm -qa|grep libaio

rpm -qa|grep net-tools

授权 chmod -R 777 /tmp

安装mysql

rpm -ivh mysql-community-common-5.7.16-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-5.7.16-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-5.7.16-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm

查看版本

mysqladmin --version

初始化服务

mysqld --initialize --user=mysql

查看密码

cat /var/log/mysqld.log

root@localhost: 后面就是初始化的密码

相关服务

启动:systemctl start mysqld.service

停止:systemctl stop mysqld.service

登录修改密码

mysql -uroot -p

ALTER USER 'root'@'%' IDENTIFIED BY 'new_password';

修改字符集

vim /etc/my.cnf

在最后加上中文字符集配置

character_set_server=utf8

并重启

systemctl restart mysqld.service

授权远程连接

grant all privileges on . to root@'%' identified by 'root';

3、问题

1)Access denied for user 'root'@'localhost' (using password: YES)

1.,vi /etc/my.cnf

在最尾部加上

skip-grant-tables

保存

3,启动mysql

systemctl start mysqld.service

4,登录musql

mysql -u root

此处注意不要加-p

5,修改密码,mysql5.7用此语法

use mysql ;

update mysql.user set authentication_string=password('123456') where user='root' ;

6,回到第二步骤去掉加上的

skip-grant-tables

保存 重启mysql就ok了

2)密码安全策略

a1cf3572e62095594ecf7d0379873edb.png

validate_password_policy类型

Policy

Tests Performed

0 or LOW

Length

1 or MEDIUM

Length; numeric, lowercase/uppercase, and special characters

2 or STRONG

Length; numeric, lowercase/uppercase, and special characters; dictionary file

修改策略方式

set global validate_password_policy=0;

9ab39ab60c22e42d2a5c144a24a43c99.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值