How do I run MySQL commands?

Problem

I need to make some ad-hoc queries or run some raw SQL commands against the MySQL database.

Solution

For a Native or fullstack installation:

  1. Log into your Open edX instance
  2. You'll need the edxapp username and password for MySQL.  
    1. The username defaults to edxapp001, and isn't usually changed.
    2. The password defaults to "password".  If you randomized passwords during installation, you'll need to find the EDXAPP_MYSQL_PASSWORD value in the passwords file.
  3. Run this command: 

    $ mysql -uedxapp001 -pTHE_PASSWORD edxapp
    Warning: Using a password on the command line interface can be insecure.
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 130
    Server version: 5.6.32-1+deb.sury.org~xenial+0.1 (Ubuntu)
    
    Copyright (c) 2000, 2016, 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>
  4. You can now use MySQL commands at the "mysql> " prompt.