# 安装mysql ``` sudo apt install mysql-server ``` # ubuntu18.04 首次登录mysql未设置密码或忘记密码解决方法 1.首先输入以下指令: ```shell sudo cat /etc/mysql/debian.cnf ``` 2.输入显示的帐号与密码 ```sql mysql -u debian-sys-maint -p ``` 3. 修改帐号与密码 1.使用mysql ```sql use mysql; ``` 2.修改帐号与密码 ```sql update mysql.user set authentication_string=password('root') where user='root' and Host ='localhost'; ``` 3.修改配置 ``` update user set plugin="mysql_native_password"; ``` 4.保存设置 ``` flush privileges; ``` 5. 退出 ``` quit; ``` 4.使用mycli ``` sudo apt install mycli ```