How to connect to Mysql database using cmd

  • 2020-05-15 02:22:07
  • OfStack

The mysql tutorial and mysql reference that we usually see on the web contain the cmd commands and result sets.
Some beginners may not know where to type these commands in the system, or start one of mysql's tools. Here's how to get into mysql's cmd mode and basic mysql's cmd operations.
window system, for example, first of all, we began to move the mouse to the lower left corner, click on "start" button, find the "run", open after the operation, input "cmd" in the input box, and then press the enter key (namely enter key), then entered the cmd mode (1 the window of the background to black, there are some English letters).
After opening cmd, we see: C:\Ducuments and Settings\Administrator > (there are some friends whose systems are not using Administrator, which is different. If you enter window and use user, then Administrator will be changed to user.)
In fact, this string of English letters refers to the position of a system. Now we enter the Administrator directory in the Ducuments and Settings directory of c disk. So, now that we know the meaning of the cmd location, what shall we do next? By the way, you have to go to mysql's bin directory to launch mysql with cmd.
Take mysql 5.0 as an example. The installation directory of mysql is MySQL Server 5.0 (C:\Program Files\MySQL\MySQL Server 5.0) in Program Files on c disk.
The steps are as follows:
C:\Ducuments and Settings\Administrator > cd\(enter key)
Appear as follows:
C:\ >
Step 2:
C:\ > cd C:\Program Files\MySQL\MySQL Server 5.0\bin(enter key)
Appeared: C:\Program Files\MySQL\MySQL Server 5.0\bin >
Step 3 :(connect to mysql server)
C:\Program Files\MySQL\MySQL Server 5.0\bin > mysql-hlocalhost-uroot-p (enter key)
(the above - hlocalhost refers to using a local user to connect to, - uroot refers to the user to connect to the user named root, - p refers to an empty password, 1 have not set a novice root user password, if you are installing mysql5. 0 time configuration server, first to you to set the root password, please remember, fill it with the above - after p)
After a successful connection, the mysql welcome and mysql version number will appear,
Then the cmd character appears as:
mysql >
That means a successful connection to the mysql server, and then you will see the command in the reference book, which is mysql > The command, you type the line here, and the result will appear in cmd.


Related articles: