How to Send Sql Queries to Mysql from the Command Line
A simple text-based program called mysql should have been part of your MySQL installation. It lets you send SQL queries directly to the MySQL server and output the results in text format. It is a quick and easy way to test your MySQL...
Table of Contents
Method 1 of 1:
Running without the console.
-
Find the mysql program (Should be in a subdirectory called bin under the directory where MySQL was installed)- E.g. Windows users: C:mysqlbinmysql.exe
- E.g. Linux/Unix users: /usr/local/mysql/bin/mysql
-
Start mysql - At the command prompt, type: mysql -h hostname -u username -p db_name -e "query"- where
- host is the machine where the MySQL server is running
- username is the MySQL account you want to use
- -p will make mysql prompt you for the MySQL account password.
- db_name is the name of the database to run the query in, and,
- query is the query that you want to run.
- where
-
Enter your password when prompted. -
MySQL should return the result of your query.
4 ★ | 1 Vote
Read More
- How to Use Net Send
- Monitor MySQL in real-time mode with mytop
- How to send email using the command line in Linux
- Backup and restore MySQL with mysql-zrm on Debian Sarge
- Command line parameter in C
- Manage the Event Log with the command line
- The Nox App Player command line parameters support
- How to check the Port to prevent the computer from sending queries automatically