如何在Ubuntu18.04系统安装mysql
如何在Ubuntu18.04系统安装mysql
MySQL是一个开源的小型关联式资料库管理系统.在Ubuntu18.04系统中,如何安装mysql?本文将针对此问题进行说明。
1.首先更新软件列表
sudo apt-get update
2.然后安装mysql-server
sudo apt-get install mysql-server
3.运行完之后输入以下指令,可以查看mysql是否运行
service mysql status
反馈

Mysql正常运行
4.登录mysql
mysql -u root -p
密码为空,进入mysql

5.设置root账号的密码
依次运行以下命令
use mysql;
update mysql.user set authentication_string=password('你的密码') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password";
flush privileges;

设置完成
6.查看debian-sys-maint用户密码
Ubuntu在安装MySQL时会为用户创建一个debian-sys-maint用户。如果忘记密码的话可以通过登录debian-sys-maint用户进行修改。
sudo cat /etc/mysql/debian.cnf

7.之后用该用户密码登录后就可以修改root密码了
mysql -u debian-sys-maint -p