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

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

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

15条回答
  •  死守一世寂寞
    2020-11-28 01:43

    To access SQL via the command line we simply navigate to the xampp folder. the folder is usually on the c:\ drive.

    1. type: cd c:\xampp\mysql\bin then press enter.
    2. type: in mysql -u root -p then press enter.
    3. in the new line enter the password of the database.
    4. type: show databases; to see all the databases that you have access to.
    5. once you know what database you want to use type (ex. cms_database), type use cms_data or any other db_name, it should say Database changed

    // Bonus Note you shouldn't use the root user when working with databases. you would want to create a separate account (ex. cms_user) with special privileges to limit errors.

    to do that type:

    GRANT ALL PRIVILEGES IN cms_database.*
    TO 'cms_user'@'localhost' 
    IDENTITIED BY 'yourpassword'
    

    double check by using the command:

    SHOW GRANT FOR 'cms_user'@localhost;
    

    if you already have the name of the user and the specific database you wish to use, change step 2 to this.

    mysql -u cms_user -p cms_database 
    

提交回复
热议问题