Run the mysql command through the command line

Source: Internet
Author: User
There are two ways to execute SQL commands under the command line. The first is to use the "-e" parameter to specify the SQL statement to be executed, and the second is to use the pipeline. Syntax and example: 1. MYSQL_HOMEbinmysql-u username-p password-D database name-esql statement usrlocalmysqlbinmysql-uroot-p123456-Dmysql

There are two ways to execute SQL commands under the command line. The first is to use the "-e" parameter to specify the SQL statement to be executed, and the second is to use the pipeline. Syntax and example: 1. MYSQL_HOME/bin/mysql-u username-p password-D database name-e "SQL statement"/usr/local/mysql/bin/mysql-uroot-p123456-Dmysql

There are two ways to execute SQL commands under the command line. The first is to use the "-e" parameter to specify the SQL statement to be executed, and the second is to use the pipeline. Syntax and example:

1. MYSQL_HOME/bin/mysql-u username-p password-D database name-e "SQL statement"/usr/local/mysql/bin/mysql-uroot-p123456-Dmysql- e "select host, user from user "; 2. echo" SQL statement "| MYSQL_HOME/bin/mysql-u user name-p password-D database name echo" select host, user from user "|/usr/local/mysql/bin/mysql-uroot-p123456-Dmysql

The preceding command execution result is as follows. The results are different.

Use Cases are often used in scripts, such as regular execution of stored procedures, load data infile, and deletion of old data.

Original article address: Execute the mysql command through the command line. Thanks to the original author for sharing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.