/*> = waiting for next line, waiting for completion of a comment that began with /*.`> = waiting for next line, waiting for completion of an identifier that began with a backtick ( `).“> = waiting for next line, waiting for completion of a string that began with a double quote ( “).‘> = waiting for next line, waiting for completion of a string that began with a single quote ( ').-> = waiting for next line of multiple-line query. ![]() There are prompts with different meanings: ![]() If you want to cancel a query, type in \c and press Enter. Multi-line queries will also occur if you didn’t end a string on a line (a word surrounded by ‘ or “). In that case, MySQL will simply enter a different prompt to let you continue your command. You can also enter multi-line queries (if you don’t include a semicolon at the end of the line before pressing Enter). You could also write: mysql> SELECT VERSION() SELECT CURRENT_DATE Since semicolon ( ) marks the end of a statement, you could also write multiple statements on a single line.įor example, instead of: mysql> SELECT VERSION() Here are some basic examples: mysql> SELECT VERSION() Īs an example, the third query would print out something similar to this: +-+-+ You can separate columns with comma ( ,). All SQL statements should be followed by a semicolon ( ), although there are exceptions (most notably: QUIT). Since MySQL uses tables, the output of queries will also be displayed in tables. ![]() Before delving into storing, accessing and modifying data, I’ll go cover basic queries so you get the hang of it. MySQL stores data in tables and uses commands called queries ( SQL = structured query language). If you want to see a list of options, use: mysql -help Using Queries in MySQL Note: Make sure you are connected to the server before inputting any of the queries I’ll be covering. You can also output info about the versionwith a simple command: sudo mysqladmin -u root version -p Typing quit (MySQL is case insensitive) or \q will also work. To disconnect from the server and leave the mysql prompt, type: QUIT If you successfully inputted the required parameters, you’ll be greeted by the MySQL shell prompt ( mysql>): For example, if the password for test_user is 1234 and you are trying to connect on the machine you are using, you could use: mysql -u test_user -p1234 h is used to specify a host name (if the server is located on another machine if it isn’t, just omit it), -u mentions the user and -p specifies that you want to input a password.Īlthough not recommended (for safety reasons), you can enter the password directly in the command by typing it in right after -p. The command for doing this is: mysql -h host_name -u user -p To be able to enter queries, you’ll first have to connect to the server using MySQL and use the MySQL prompt. Connecting to & Disconnecting from the MySQL Server ![]() Note: MySQL queries (commands) are case-insensitive however, it is common practice to use ALL CAPS for the actual command keywords and lowercase for the rest. In this article I’ll be presenting to you multiple MySQL features, mostly sticking to the basics. Last week, I covered installing and configuring MySQL in Ubuntu. Its ease of use and open source license have greatly contributed to this popularity. MySQL is the most commonly used relational database manager. Brief: Learn to use basic SQL commands in the open source database management system MySQL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |