How to Connect to MySQL from Windows Command Line

Configurare noua (How To)

Situatie

MySQL is a popular and open-source relational database application. Therefore, many servers make use of MySQL. The way you access the database depends on the operating system from which you are working.

Solutie

Pasi de urmat

Start by opening the Run command box in Windows. Use the keyboard shortcut – hold the Windows (super) key and press the letter R (Win+R).

Then, type in cmd and press Enter. This command opens the Windows command line.

Next, run the command to display a list of all the services that are currently running. Enter the following in the command prompt:

net start

net start windows command line

If MySQL is not on the list, you can start it using the Services panel. Enter the following command:

services.msc

A new window will launch and display the list of services available on your system. Scroll down to find MySQL, and check the status column. Left-click the MySQL service to highlight it, then right-click to open a context menu. Finally, left-click on start.

Connect to a Local MySQL Server

First, start MySQL in Windows using the following command:

mysql.exe -u[username] -p

Replace [username] with the username for your MySQL installation.

Enter mysql.exe -uroot -p, and MySQL will launch using the root user.

MySQL will prompt you for your password. Enter the password from the user account you specified with the –u tag, and you’ll connect to the MySQL server.

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.7.11-log MySQL Community Server (GPL)

The command prompt changes to look like this:

mysql>

Change to the MySQL folder, use the cd command:

cd c:\Program Files\MySQL

The command prompt should change to mysql> letting you know you’re currently in the MySQL folder.

To list the contents of this folder:

dir

This lists the contents of the current folder. One of the folders will display the version number of your MySQL installation.

For example, if you’ve installed MySQL 5.5, you should see a folder named “MySQL Server 5.5”.

Tip solutie

Permanent

Voteaza

(7 din 13 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?