方法一:通过设置client标签,直接编辑/etc/my.cnf文件
[client]
user=root
password=123456
port = 3306
我们直接输入mysql就可以进行登录mysql数据库,这种不好的地方就是我们的密码是不加密的,可见的,是不安全的。
[root@tz-ftp-yum ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.7.25-log MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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.