How to Use cmd to connect to a Mysql database

Source: Internet
Author: User

We usually see mysql tutorials and mysql tool books on the Internet, which contain cmd commands and result sets.
Some beginners may not know which corner of the system to enter these commands, or start some mysql tools. The following describes how to enter the cmd mode of mysql and basic cmd operations of mysql.
Take the window system as an example. First, move the cursor to the lower-left corner to start. Click Start and find run. After the run is started, Enter cmd in the input box ", then press enter to enter the cmd mode (a black window with some English letters ).
Open cmd and we can see: C: \ Ducuments and Settings \ Administrator> (some of my friends use different systems than the Administrator users, if the user you use to access the window system is user, the Administrator is changed to user)
In fact, this string of English letters represents a system location. Now, the location after cmd is: Under the Administrator directory in the Ducuments and Settings directory of drive C, now that we know the location of the cmd, what should we do next? By the way, you need to enter the bin directory of mysql to start mysql with cmd.
Take mysql5.0 as an example. The mysql installation directory is MySQL Server 5.0 (C: \ Program Files \ MySQL Server 5.0) in MySQL in the Program Files directory of drive C, we are ready to enter this directory.
The procedure is as follows:
C: \ Ducuments and Settings \ Administrator> cd \ (enter key)
The following figure is displayed:
C: \>
Step 2:
C: \> cd C: \ Program Files \ MySQL Server 5.0 \ bin (enter key)
The following error occurs: C: \ Program Files \ MySQL Server 5.0 \ bin>.
Step 3: (connect to the mysql server)
C: \ Program Files \ MySQL Server 5.0 \ bin> mysql-hlocalhost-uroot-p (enter key)
(The above-hlocalhost refers to the connection by a local user,-uroot refers to the connection by a user with the username root, and-p refers to a blank password, generally, you have not set the root user password for beginners. If you have configured the server when installing mysql5.0 and want to set the root password for the first user, remember, after filling in the above-p)
After successful connection, the welcome message of mysql and the mysql version number will appear,
Then the cmd drive letter is:
Mysql>
The connection to the mysql server is successful. Then you can see the command in the tool book, which is mysql> command. Enter the command here and the result is displayed in cmd.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.