有时候有人想偷懒,直接免密登录mysql。可以按照以下方法操作
1.编辑配置文件
vim /root/.my.cnf
[client]
user=root
password=123
2.修改权限
chmod 400 ~/.my.cnf
3.登录查看
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.7.20-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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.www.wityx.com/database
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root@localhost :(none)12:09:35>
可以了,现在能免密登录了!