自学内容网 自学内容网

ubuntu安装mysql 8,mysql密码的修改

1.安装mysql 8

apt install mysql-server-8.0

在这里插入图片描述
敲 Y 按回车
在这里插入图片描述
table 选ok

2.查看当前状态

service mysql status

在这里插入图片描述
显示active(running)证明安装成功!

3.手动给数据库设置密码

mysql5

alter user 'root'@'localhost' identified by 'newpassword''

mysql8

1.如果代码不为空:
use mysql
update user set authentication_string=' ' where user = 'root'; (将字段置为空)
alter user ‘root’@‘localhost’ identified by ‘newpassword’;(修改密码为newpassword) 
2.如果为空,直接修改
alter user ‘root’@‘localhost’ identified by ‘newpassword’;(修改密码为newpassword) 

在这里插入图片描述

4.直接把数据库验证密码的功能关闭掉

 cd /etc/mysql/

mysql默认在这个目录下
在这里插入图片描述
进入这个配置文件中

 cd mysql.conf.d

在这里插入图片描述

进入mysqld.cnf

vim mysqld.cnf

在这里插入图片描述

在这里按 “i” 输入

skip-grant-tables

这个配置会影响部署!(但是在mysql 5 可以)
在这里插入图片描述
保持退出即可

在这里插入图片描述
保存退出后,程序启动

mysql restart

原文地址:https://blog.csdn.net/m0_74312445/article/details/142557742

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!