debian-sys-maint是个安装之后自带的用户,具体作用是重启及运行mysql服务。
忘了root密码就该他大显身手了。
root@ms:/etc# cd mysql/
root@ms:/etc/mysql# vi debian.cnf
user = debian-sys-maint
password = *******************************
把密码粘贴出来 用这个用户密码登录mysql
root@ms:/etc/mysql# mysql -u debian-sys-maint -pEnter password:**********
登录进来:
mysql> use mysqlmysql> update user set password=password('新密码') where user='root';
报错了!
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
别慌,很简单。
mysql> update user set authentication_string=password('新密码') where user='root';Query OK, 0 rows affected, 1 warning (0.03 sec)Rows matched: 1 Changed: 0 Warnings: 1mysql> exit;
root@ms:/etc/mysql# mysql -u root -pEnter password:刚才设置的密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 Server version: 5.7.19-0ubuntu0.16.04.1 (Ubuntu)