1、通过 whereis mysql查看安装路径
2、查看MySQL用户文件
sudo vi /etc/mysql/debian.cnf
3、使用文件内的user(用户名)password(密码)登录MySQL
mysql -u(用户名) -p(密码)
4、数据库操作
show databases; #查看所有的数据库
use mysql; #使用mysql库
select host, user from user; #查询表
update user set authentication_string=password('设置的密码') where user='root'; #修改密码字段
5、退出
quit
6、切换到root用户
su root
7、在root用户下操作
mysql -u root -p xxx(‘设置的密码’)
8、重复第四步
update user set host='%' where user='root'; #修改权限
9、授权
grant all privileges on *.* to 'root'@'%' identified by 'xxx(设置的密码)' with grant option;
10、刷新系统权限
flush privileges;
11、退出切换原用户使用mysql -u root -p 'xxx(设置的密码)'登录了