首页 > 代码库 > 关于MySQL的密码

关于MySQL的密码

设置密码:

mysqladmin -uroot password ‘111‘  单实例设置密码
mysqladmin -uroot password ‘aaa‘ -S /data/3307/mysql.sock  多实例设置密码

修改密码:

1, shell命令行修改:
mysqladmin -uroot -p111 password ‘aaa‘
mysqladmin -uroot -p111 password ‘aaa‘ -S /data/3306/mysql.sock
2,登陆MySQL修改:
update mysql.user set password=password(‘aaa‘) where user=‘root‘ and host=‘localhost‘;
flush privileges;
3,登陆MySQL后set:
set passwor=password(‘aaa‘);
flush privileges;

单实例找回密码:

1、关闭MySQL:
/etc/init.d/mysqld stop
2、跳过授权表启动:
mysqld_safe --skip-grant-tables &
3、进入数据库后update:
update mysql.user set password=password(‘aaa‘) where user=‘root‘ and host=‘localhost‘;
4、重新启动:
/etc/init.d/mysqld stop
/etc/init.d/mysqld start

多实例找回密码:

killall mysqld
mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables &
update mysql.user set password=password(‘aaa‘) where user=‘root‘ and host=‘localhost‘;
mysqladmin -uroot -paaa -S /data/3306/mysql.sock shutdown

  

  

  

关于MySQL的密码