ubuntu 16
apt install mysql*
查看初始user和password
root@hecs-279155:~# cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = tvXfL92IdUcTEH8c
cent os7查看初始密码
systemctl start mysqld
grep "password" /var/log/mysqld.log
修改密码:
1使用命令
mysqladmin -uroot -pWp1@mysql.com password WP1@mysql.com
2使用数据库命令
mysql -uroot -p
set password for 用户名@localhost = password('新密码'); 一定不要忘记最后面的分号
3改数据库数据
1)、use mysql; #连接到mysql数据库
2)、update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost'; #修改密码123456是密码
3)、update user set plugin="mysql_native_password";
4)、flush privileges;
5)、quit;