文档课题:mysql实现root用户免密码登录.
数据库:mysql 5.7.42
1、方案一
1.1、修改my.cnf文件
--添加如下配置跳过授权表
skip-grant-tables
1.2、重启mysqld服务
# systemctl stop mysqld
# systemctl start mysqld
1.3、修改密码
# mysql -uroot -p
说明:此时不需要输入密码.
mysql> use mysql
--设置密码
mysql> update user set authentication_string=password('mysql5721_4U'),password_expired='N',password_last_changed=now() where user='root';
--刷新授权表
mysql> flush privileges
1.4、还原my.cnf配置
说明:退出mysql且删除配置文件里的skip-grant-tables,然后重启mysql服务.
2、方案二
[root@leo-mysql5721 ~]# vi .my.cnf
添加如下内容:
[client]
host=localhost
user=root
password=mysql_4U
port=3306
[root@leo-mysql5721 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
mysql实现root用户免密码登录
原创Liujun_Deng 博主文章分类:Mysql ©著作权
文章标签 MySQL root用户免密登录 文章分类 MySQL 数据库
-
域用户免登录失败的解决方式
解决方式:Administrator安装+设置环境变量+重装客户端+重启电脑
环境变量 域用户 免登录 -
Linux Mysql 实现root用户不用密码登录
1、修改mysql配置文件,达到不用密码登录首先vim /etc/my.conf2、尾部追加skip-grant-ta
mysql linux 服务器 重启 mysql配置 -
MySQL用户设置密码后,如何免密登录
mysql
mysql 免密登录 -
mysql 配置本地root免密登录 配置mysql密码
MySQL安装完毕后我们需要对它进行一些设置及性能优化,主要包括字符集设置,启动设置,连接优化,表优化,分区优化等等。 一 修改MySQL密码及用户  
mysql 配置本地root免密登录 数据库 操作系统 shell mysql