mysql command line

You can connect to mysql database from the command line:

mysql -u username -p -h IP -P port

and then issue you queries.

The mysql program is a general purpose client that sends SQL statements to the server, and thus can perform any administrative operation that can be expressed using SQL:

  1. Create and drop databases.
  2. Create, drop, and modify tables and indexes.
  3. Retrieve data from tables.
  4. Modify data in tables.
  5. Set up user accounts, grant and revoke privileges, and set passwords.
  6. Display or reset server status variables.
  7. Reload the grant tables.
  8. Flush the log files or various server caches.
  9. Start or stop replication slave server or display replication status
  10. Display information about client connections or kill connections.

You can use mysql in interactive mode, where you type in queries and see results. mysql also can operate in batch mode, in which it reads queries stored in a text file.

Statement terminators:

You may use any of the several terminators to end a statement. ';' and \g are equivalent. \G also terminates queries, but causes mysql to display query results in a vertical style. The \G terminator is especially useful if a query produces very wide output lines because vertical format can make the result much easier to read.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License