在LUNIX中安装MYSQL

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum -y install mysql-server

#尝试开启mysql服务

systemctl start mysqld

#查看服务状态

systemctl status mysqld

#关闭服务进行字符集配置

systemctl stop mysqld
vim /etc/my.cnf
-------------------------------------------
[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
datadir=/opt/software/mysql57/data
-------------------------------------------

#命令行生成并获取临时密码

grep 'temporary password' /var/log/mysqld.log
2021-05-25T04:14:58.813447Z 1 [Note] A temporary password is generated for root@localhost: pj7d2lW=,7n*

#利用临时密码登录,并修改密码

mysql -u root -ppj7d2lW

#如果 /var/log/mysqld.log 中不存在初始化临时密码
#通过以下途径设置免密登录

#1、关闭Mysql服务
		systemctl stop mysqld
	#2、修改匹配文件启动免密登录
		vim /etc/my.cnf
		[mysqld]
		skip-grant-tables
	#3、启动mysql服务
		systemctl start mysqld
	#4、免密登录
		mysql #回车
	#5、立即修改本地访问root账号密码后退出mysql
		use mysql;
		update user set password/authentication_string=password('1234') where user='root';
		exit;
	#6、关闭mysql服务,删除配置信息skip-grant-tables
		#再次启动mysql服务后可以使用之前修改的密码正常登录
	#7、必须在进行其他操作前修改符合密码策略要求的密码
		alter user 'root'@'localhost' identified by '@12A3a4pola';
	#7.1、如果需要修改密码难度等级
		set global validate_password_policy=0;
		flush privileges;
	#7.2、再次重置密码:最小长度8
		alter user 'root'@'localhost' identified by '12345678';
	#8、启动远程访问
		grant all on *.* to root@'%' identified by 'kb12kb12';
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值