EDUCBA

EDUCBA

MENUMENU
  • Blog
  • Free Courses
  • All Courses
  • All in One Bundle
  • Login
Home Data Science Data Science Tutorials MySQL Tutorial Cheat Sheet MySQL

Cheat Sheet MySQL

By Priya PedamkarPriya Pedamkar

Cheat Sheet MySQL

Introduction to Cheatsheet MySQL

MySQL is an open-source database management system. Cheatsheet MySQL has many features, making it more flexible and extensible. MySQL is free, meaning no need to pay to use it. It can handle large sets of the functionality of expensive and powerful database packages. It mainly works quickly and well with an extensive collection of data. One of the great features of cheat sheet MySQL is customizable; it can be modified into specific environments.

MySQL

MySQL mainly works well with various programming languages like C, PHP, Perl, etc. PHP is primarily used with MySQL only. It is a reliable database, and it gives great performance and ensures data security while connecting with programming languages through different modes. MySQL is referred to as a relational database management system (RDBMS). MySQL database is mainly available only in one language, that is the English language. It was developed by Oracle Corporation and released in the year 1995. It supports multiple operating systems like Windows, Mac OS, Linux, Solaris, Free BSD, etc. C and C++ were used for developing MySQL.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Commands and Content on Cheat Sheet MySQL

Cheatsheet MySQL has an extensive library, scalable, extendable, and interactive, and contains many in-built methods to compute common operatioDifferent commands areands available to perform command-line operate; each command has both short and long-form. The long form is not case-sensitive, but the short form is case-sensitive. Below are the Cheatsheet MySQL commands mentioned, which perform different kinds of operations:

Command Description
help, \h, \? It will display the available MySQL commands
Clear, \c It clears the user input
Connect,\r Connect to the server.
Delimiter, \d It sets the statement delimiter.
Edit, \e Edit the command with $EDITOR.
Ego,\G It displays the result vertically.
Exit, \q It will exit or quit or close MySQL.
Go,\g It will send a command to the SQL server.
Nopager, \n It displays the pager, print to stdout.
Notee, \t Don’t write to outfile.
Pager,\P Set pager and print the results via pager.
Print, \p It will print the current command
Prompt, \R Change the MySQL prompt.
Rehash, \# Rebuild completion hash.
Tee,\T Set outfile and append into outfile
Source, \. Execute an SQL script file.
Status, \s It will get the information on the status from the server
The system, \! Execute the system shell command.
Use, \u Use another database, with the help of the DB name as an argument.
Charset, \C Defining the charset.
Warnings, \W It will show a warning at the end of each statement.
Nowarning,\w It will not show a warning after every statement.
Resetconnection, \x It will clean the session context.

Data types: MySQL has different data types used for inserting specific values in database columns. For integers using ‘int’. Similarly, other like float, double, timestamp, char, varchar, bland, and enum is used to insert values.

String functions: There are string functions available for use as well:

String function Description
strcmp(s1, s2) Comparing the strings
Lower(s) Convert to lowercase
Upper(s) Convert to upper case
Substring(s, index1, index2) Taking the substring of string
Ltrim(s) Left-trim
Curdate() Get today’s date
Curtime() Get the time.
Dayname(s) If we have to extract the name of the day.
Dayofweek(s) Extract the particular day number.
Monthname(s) If a month needs to be extracted.

Mathematical Functions: – The different functions available in MySQL’s math module are:

Function Description
COUNT(*) Count the rows per group
AVG(column) The average value of a group
MIN(column) A minimum value of a group
MAX(column) A maximum value of a group
SUM(column) Sum values in group
Abs(number) Absolute value
Round(number) Rounding number
Floor(number) The number is the largest integer but not greater
Ceiling(number) Smallest integer, not the smaller
Sqrt(number) Square root
Pow(base, exponent) nth power
Rand() Random number
Sin(number) Sin function
Cos(number) Cos function

Free Tips and Tricks for Using Cheatsheet MySQL Commands

  1. In the cheat sheet MySQL, if a list of all databases is required then use the command’ SHOW DATABASES;’ to get the available databases.
  2. The ‘CREATE DATABASE dbname;’ command is used to create a new database.
  3. To use the particular database, command ‘USE database;’ is used.
  4. The ‘SHOW TABLES;’ command needs to use the list of all tables in the MySQL database.
  5. ‘Describe table; Show Columns from a table;’ commands are used to show the structure of the table.
  6. ‘DROP DATABASE dbname;’ command is used to delete a database. Please be careful in using this command, after executing the rollback cannot be done.
  7. If duplicate data is not required while selecting the data from a table, the DISTINCT keyword should be used to not to repeat the duplicate data. A query can be: Select a DISTINCT column from a table;
  8. There are other queries as well for Inserting, updating, deleting, ordering, grouping the columns, joins of two or more tables. These make the data processing faster and retrieved easily.
  • Inserting: Insert into table values (v1, v2);
  • Inserting column: Alter table tablename ADD column columntypeoptions;
  • Updating: update table set column1=x where 1=1 (conditions);
  • Deleting: Delete from table where 1=1(conditions);
  • Deleting the column: Alter table tablename Drop column columname;
  1. If there is forgot root password, use below commands:

$ /etc/init.d/mysql stop

$ mysqld_safe –skip-grant-tables &

$ mysql # on another terminal

mysql> UPDATE mysql.user SET password=PASSWORD(‘[email protected]’) WHERE user=’root’;

$ /etc/init.d/mysql start

  1. If the table needs to repair after a shutdown is not proper:

mysqlcheck –all-databases –fast

  1. If the data needs to be loaded from the file, use the below command:

mysql> SOURCE input_file

$ mysql database < filename.sql

$ cat filename.sql | mysql database

Conclusion – Cheat Sheet MySQL

Cheat sheet MySQL is easy to use, its syntax is easier to remember, and the queries can be written easily. It can be used with any web technology to store the data. It is secure and faster to perform. Its structure is easy to work on and understand. The simple language is used which makes it easier to learn for beginners.

MySQL is mainly used for UNIX like operating systems and is integrated very easily. This can be used on cloud platforms, which is the latest thing in the market. It can be easily moved or hosted on Amazon or Azure cloud platform services.

Recommended Articles

We hope that this EDUCBA information on “Cheat Sheet MySQL” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. Cheat sheet for UNIX
  2. Cheat Sheet CCNA
  3. Java Cheat Sheet
  4. Cheat sheet CSS3
C++ PROGRAMMING Certification Course
38+ Hours of HD Videos
9 Courses
5 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
ASP.NET Certification Course
149+ Hours of HD Videos
28 Courses
5 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
SQL - Everything in SQL
253+ Hours of HD Videos
51 Courses
6 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
SOFTWARE TESTING Certification Course
74+ Hour of HD Videos
13 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
Primary Sidebar
Popular Course in this category
MYSQL Certification Course
 115+ Hours of HD Videos
18 Courses
3 Mock Tests & Quizzes
  Verifiable Certificate of Completion
  Lifetime Access
4.5
Price

View Course
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

🚀 Hurry! - Any Learning Path @ $19 | OFFER ENDING IN ENROLL NOW