1.设置root密码(root密码为空时)
mysqladmin -uroot password "new123";
2.修改mysql密码(3种方法)
1)mysqladmin -uroot -poldboy123 password "new123"; 2)mysql>update mysql.user set password=password("oldboy123") where user='root' and host='localhost'; mysql>flush privileges; 3)mysql> set password=password("123");
3.忘记密码
1)首先关闭mysql 2) 跳过验证启动 mysqld_safe --skip-grant-tables & 3)使用修改mysql密码的方式进行修改建议(第二种方法) 4)重新启动mysql
4.创建超级用户
mysql> grant all privileges on *.* to 'system'@'localhost' identified by 'oldboy123' with grant option; mysql> flush privileges;
5.多实例mysql修改密码
mysqladmin -uroot -poldboy123 password "new123" -S /data/3306/mysql.sock
6.忘记密码
mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables &