1.mysql -uroot -poracle -h
这种方式登入mysql ,非常不安全,其他可以通过 history fc 等看到相关用户的密码信息
[root@lixora ~]# fc -l
1150 mysql --login-path=lixora
1151 mysql --login-path=admin
1152 mysql -uroot -poracle ---密码直接明文显示
1153 mysql -uroot -pmysql ---密码直接明文显示
考虑到系统的安全问题,这种登入方式还是不要再用了
2.mysql -uroot -p
安全问题是已经避免了,但是对于维护人员来说好像有点麻烦,每次登server 时都要敲
3.这里建议采用一个相对安全,简单,快捷的登入方式 login-path:
配置如下:(loging-path可以自定义,缺省是client,若要登入多个server,不同账户,需要指定不同的login-path名,否者会覆盖原来的配置信息)
这种方式登入mysql ,非常不安全,其他可以通过 history fc 等看到相关用户的密码信息
[root@lixora ~]# fc -l
1150 mysql --login-path=lixora
1151 mysql --login-path=admin
1152 mysql -uroot -poracle ---密码直接明文显示
1153 mysql -uroot -pmysql ---密码直接明文显示
考虑到系统的安全问题,这种登入方式还是不要再用了
2.mysql -uroot -p
安全问题是已经避免了,但是对于维护人员来说好像有点麻烦,每次登server 时都要敲
3.这里建议采用一个相对安全,简单,快捷的登入方式 login-path:
配置如下:(loging-path可以自定义,缺省是client,若要登入多个server,不同账户,需要指定不同的login-path名,否者会覆盖原来的配置信息)
[root@qht131 mysql]# mysql_config_editor set --login-path=lixora --user=root --password
Enter password:
缺省会在用户根目录下生成一个隐藏文件 .mylogin.cnf 这个文件是加密过的,也不是2进制文件
mylogin.cnf 的里的配置信息只能通过mysql_config_editor print --all 来查看,密码会自动用星号替代:
[root@qht131 ~]# ls -l .mylogin.cnf
-rw-------. 1 root root 120 Jun 27 19:19 .mylogin.cnf
[root@qht131 ~]# mysql_config_editor print --all
[root]
[lixora]
user = root
password = *****
[root@qht131 ~]#
使用login-path 登入 mysql server:
[root@qht131 ~]# mysql --login-path=lixora
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.21-log 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>
--添加远程mysql server登入配置信息:
[root@qht131 ~]# mysql_config_editor set --login-path=lixora-remote --user=root --password --host 172.17.61.131
测试环境只有一台mysql,所以ip指的是本机IP
测试连接:
[root@qht131 ~]# mysql --login-path=lixora-remote Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.21-log 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>