How can I access the MySQL command line with XAMPP for Windows?

前端 未结 15 2234
甜味超标
甜味超标 2020-11-28 00:54

How can I access the MySQL command line with XAMPP for Windows?

相关标签:
15条回答
  • 2020-11-28 01:30

    To access MySQL in Windows you need to install the XAMPP.

    • Open the XAMPP Control Panel and start MySQL.
    • Now go to the command prompt and open

      C:\>cd xampp
      C:\xampp>cd MySQL 
      C:\xampp\mysql>cd bin 
      C:\xampp\mysql\bin>mysql -h localhost -u root
      

    Your database is now ready to be executed.

    0 讨论(0)
  • 2020-11-28 01:30

    I had the same issue. Fistly, thats what i have :

    1. win 10
    2. xampp
    3. git bash

    and i have done this to fix my problem :

    1. go to search box(PC)
    2. tape this environnement variable
    3. go to 'path' click 'edit'
    4. add this "%systemDrive%\xampp\mysql\bin\" C:\xampp\mysql\bin\
    5. click ok
    6. go to Git Bash and right click it and open it and run as administrator
    7. right this on your Git Bash winpty mysql -u root if your password is empty or winpty mysql -u root -p if you do have a password
    0 讨论(0)
  • 2020-11-28 01:32

    Xampp control panel v2.3.1 I got errors while using -h localhost

    mysql -h localhost -u root

    ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10060) 
    

    So, if you installed xampp as is and did not customize any documentroot, serverroot, etc. then the following works :-

    start both the services on the xampp control panel click shell enter: # mysql -h 127.0.0.1 -u root

    that works just fine. Below is the logtrail:-

    # mysql -h 127.0.0.1 -u root
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1
    Server version: 5.6.21 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql>
    
    0 讨论(0)
  • 2020-11-28 01:35
    1. Open the XAMPP control panel.
    2. Click Shell.
    3. Type mysql --user=your_user_name --password=your_password.
    0 讨论(0)
  • 2020-11-28 01:37

    run xampp shell to solve connect to root using pw

    mysql -h localhost -u root -p and enter root pw

    0 讨论(0)
  • 2020-11-28 01:39

    In terminal:

    cd C:\xampp\mysql\bin
    
    mysql -h 127.0.0.1 --port=3306 -u root --password
    

    Hit ENTER if the password is an empty string. Now you are in. You can list all available databases, and select one using the fallowing:

    SHOW DATABASES;
    USE database_name_here;
    
    SHOW TABLES
    DESC table_name_here
    SELECT * FROM table_name_here
    

    Remember about the ";" at the end of each SQL statement.

    Windows cmd terminal is not very nice and does not support Ctrl + C, Ctrl + V (copy, paste) shortcuts. If you plan to work a lot in terminal, consider installing an alternative terminal cmd line, I use cmder terminal - Download Page

    0 讨论(0)
提交回复
热议问题