vi /etc/my.cnf
添加到配置文件里面放在[mysqld]下面
[mysqld]
skip-grant-tables
重启服务
systemctl restart mysql
登录:mysql
mysql> update mysql.user set password=password('root') where user='root' and host='localhost';
再次回到 /etc/my.cnf 把刚才添加的内容 删除了
systemctl restart mysql
mysql -uroot -proot
MariaDB [(none)]> ALTER USER "root"@"localhost" IDENTIFIED BY "chinaskill123";
标签:免密,登录,MySQL,cnf,mysql,root,localhost
From: https://www.cnblogs.com/-liunian/p/17411259.html