In general, to enter the MySQL command mode, you always need to enter the password as follows to enter the command line mode:
Zhanhailiang @ linux-06bq: ~> Mysql-u sl-p
Enter password:
In fact, we can use reverse CT to write scripts to allow communications between reverse CT and shell to achieve password-free login:
Zhanhailiang @ linux-06bq: ~> Cat mysql. sh
#! /Usr/local/bin/CT
Spawn/usr/local/services/mysql/bin/mysql-u sl-p
CT {
"Assword" {send "slr "}
}
Interact
In fact, this script means "execute/usr/local/services/mysql/bin/mysql-u sl-p and wait for the response. If it matches assword, then, send the sl (MySQL user logon password) and press enter to simulate manual operations ".
After writing the mysql. sh script, grant the execution permission, and then run mysql. sh to enter the MySQL command line mode without a password.
Zhanhailiang @ linux-06bq: ~> Chmod + x mysql. sh
Zhanhailiang @ linux-06bq: ~> ./Mysql. sh
Spawn/usr/local/services/mysql/bin/mysql-u sl-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 12912
Server version: 5.5.14-log MySQL Community Server (GPL)
Copyright (c) 2000,201 0, 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>
Note: Regular CT has many parameters and rich application scenarios. If you are interested, please check the man manual or other materials on your own.