mysql初使用修改密码及远程登陆

  1. 第一步:查看密码
root@evo:sudo cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = cfhuKqdMEd8ozBb2
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = cfhuKqdMEd8ozBb2
socket   = /var/run/mysqld/mysqld.sock
  1. 第二步:进入数据库修改密码
root@evo: mysql -u debian-sys-maint -p
Enter password: 

mysql> use mysql;
mysql> update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost';
mysql> update user set plugin="mysql_native_password"; 
mysql> flush privileges;
  1. 第三步:修改远程访问
mysql> grant all on *.* to 'root'@'%' identified by '123456';
mysql> flush privileges;
mysql> quit
  1. 第四步:重启数据库
root@evo: service mysql restart
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容