Как подключиться к sql через командную строку
Перейти к содержимому

Как подключиться к sql через командную строку

  • автор:

How to connect from windows command prompt to mysql command line

The cd in your question is invalid (quoting it here because you’ve removed it once, and it was there when this answer was posted):

You can’t cd to CD:\ anything, because CD:\ isn’t a valid directory in Windows. CD: would indicate a drive, except that drives are restricted to a single letter between A and Z .

If your \MYSQL\BIN is on drive C: , then your commands need to be:

If you’re not already on C: (which you’ll know by looking at the prompt in the cmd window), or your MySQL folder is on another drive (for instance, D: ), change to that drive too:

The .exe after mysql is optional, since .exe is an executable extension on Windows. If you type mysql , Windows will automatically look for an executable file with that name and run it if it finds it.

Note that in both my examples of running mysql , there are no = signs. You should just use -p with no password, and wait to be prompted for it instead.

then type password

Code Lღver's user avatar

C:\Program Files\MySQL\MySQL Server 5.7\bin> mysql -u username -p

Then it will ask for the password. Enter the password you set for the username during installation while adding db Users. In the given image depp is my username

Ramandeep Singh's user avatar

first type cmd then the windows command prompt will appear:

  • -u is the user id
  • -p is the password, if you will not using a password just leave it blank.

Wilq's user avatar

You are logging in incorrectly; you should not include = in your login. So to log in, type:

If that doesn’t work, then you may not have your system configured. If so, then here’s a good tutorial on getting started with the MySQL prompt: http://breakdesign.blogspot.com/2007/11/getting-started-with-php-and-mysql-in_11.html

  1. Start your MySQL server service from MySQL home directory. Your one is C:\MYSQL\bin\ so choose this directory in command line and type: NET START MySQL
    (After that you can open Windows Task Manager and verify in Processes tab is mysqld.exe process running. Maybe your problem is here.)
  2. Type: mysql -uuser-p [pressEnter]
  3. Type your password [pressEnter]

or make a start.bat file:

  1. add C:\MYSQL\bin\ to your PATH
  2. write a start.bat file My start.bat file has only two lines like below:
    net start MySQL
    mysql -u root -p

Please perform the following steps

    First, open your command prompt with Administrator.

Go to MySQL installed directory and copy path and past on command prompt like:- C:\Program Files\MySQL\MySQL Server 5.7\bin>

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -p [-u for username -p for password]

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -p Enter password: **** [enter your password here]

1 first image

Siong Thye Goh's user avatar

Ravindra Kumar's user avatar

To make it easier to invoke MySQL programs, you can add the path name of the MySQL bin directory to your Windows system PATH environment variable:

On the Windows desktop, right-click the My Computer icon, and select Properties.

Next select the Advanced tab from the System Properties menu that appears, and click the Environment Variables button.

Under System Variables, select Path, and then click the Edit button. The Edit System Variable dialogue should appear.

Place your cursor at the end of the text appearing in the space marked Variable Value. (Use the End key to ensure that your cursor is positioned at the very end of the text in this space.) Then enter the complete path name of your MySQL bin directory (for example, C:\Program Files\MySQL\MySQL Server 8.0\bin ).

Open a different terminal and if you are using root as user run mysql -u root -p else use the a different username you created.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *