Home >Database >Mysql Tutorial >How to connect mysql to the database
Connection method: 1. Open the DOS window, enter the directory "mysql\bin", execute the command "mysql -u root -p", enter the password to connect to the local mysql. 2. Execute "mysql -hip address -u root -p password;" to connect to remote mysql.
The operating environment of this tutorial: windows7 system, mysql8.0 version, Dell G3 computer.
mysql command user to connect to the database.
mysql command format: mysql -h host address -u username -p user password
1) Connect to MYSQL on this machine
First open the DOS window, and then Enter the directory mysql\bin, then type the command mysql -u root -p. After pressing Enter, you will be prompted to enter your password.
Note that the username may or may not have spaces before it, but there must be no spaces before the password, otherwise you will be asked to re-enter your password.
If MYSQL has just been installed, the super user root does not have a password, so just press Enter to enter MYSQL. The MYSQL prompt is: mysql>
2) Connect to MYSQL on the remote host
Assume that the IP of the remote host is: 110.110.110.110, the user name is root, and the password is abcd123. Then type the following command:
mysql -h110.110.110.110 -u root -p 123; (Note: There is no need to add a space between u and root, and the same applies to others)
3) Exit MYSQL command
exit (Enter)
Related recommendations: "mysql tutorial"
The above is the detailed content of How to connect mysql to the database. For more information, please follow other related articles on the PHP Chinese website!