Connect to MySQL:
Format: mysql -h host address -u username -p user password
1. Example 1: Connect to MYSQL on this machine
Find the installation directory of mysql. Generally, you can directly type the command mysql - uroot -p, press Enter to prompt you to enter the password. If MYSQL has just been installed, the super user root does not have a password, so you can enter MYSQL directly by pressing Enter. The MYSQL prompt is: mysql>
2. Connect to MySQL on the remote host
Assume that the IP of the remote host is: 10.0.0.1, the user name is root, and the password is 123. Then type the following command:
mysql -h10.0.0.1 -uroot -p123
(Note: u and root do not need to add spaces, the same goes for others)
3. Exit the MySQL command
exit (Enter)