可能重复:
How do I change the password of the root user in MySQL?
我有root访问ec2实例,但我不知道mysql root密码是什么,我需要它。我怎么能1)找到这个?或者2)重新安装mysql并给自己一个root密码?
答案 0 :(得分:1)
$ sudo service mysql stop
$ /usr/bin/mysqld_safe --skip-grant-tables &
mysql -h localhost
> use mysql
> update user set password = password('') where user = 'root' and host='localhost';
> quit
$ sudo service mysql start
$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.