ubuntu 18.04 安装MySQL5.7

 

1、查看是否按照mysql服务:发现没有mysql服务

 

 

 

2、开始安装mysql5.7各服务

~ sudo apt-get install mysql-client-core-5.7

 

~   sudo apt-get install mysql-client-5.7

 

 ~ sudo apt-get install mysql-server-5.7 

 

 

 3、查看mysql服务状态 并重启

~ sudo service mysql status

~  sudo service mysql start

 

 

4、步骤2安装过程中 没有提示设置密码,所以在这里连接mysql时总是提示没权限,也不知道用户和密码是什么

(ubuntu 18.04 下使用apt-get 命令安装mysql后,中途是没有出现让我们设置密码的地方的)

 

 

5、最后在 /etc/mysql/debian.cnf 中找到 默认MySQL数据库登陆用户以及随机密码的保存信息

 

 

6、使用在debian.cnf中的用户和密码连接mysql 并修改root账号密码

~  mysql -h localhost -u debian-sys-maint -p 

 

> use mysql 

>  update user set authentication_string=password('justphp') where user='root' and host='localhost';  # 将root的密码设置为justphp

> update user set plugin="mysql_native_password";

> flush privileges;  # 刷新权限表 

 

 

 

 7、重启mysql服务后 验证更新的root密码是否生效

 

 

posted @ 2022-06-03 17:06  r1-12king  阅读(1500)  评论(0编辑  收藏  举报