Home  >  Article  >  Database  >  How to connect mysql to the database

How to connect mysql to the database

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-05-11 17:10:4549654browse

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.

How to connect mysql to the database

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn