服务器本地免密码连接数据库
[root@localhost ~]# vim ~/.my.cnf
[mysql]
socket=/dev/shm/mysql.sock
[client]
host=localhost
user='root'
password='这是root帐号的密码'
[root@localhost ~]# chmod 000 ~/.my.cnf
[root@localhost ~]# /program/mysql/bin/mysql # 不需要指定帐号和密码就能直接连上数据库
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 57
Server version: 5.7.17 Source distribution
Copyright (c) 2000, 2016, 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> EXIT;
Bye
[root@localhost ~]#