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 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.
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:
|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:
|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|
|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:
|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|
|Floor(number)||The number is the largest integer but not greater|
|Ceiling(number)||Smallest integer, not the smaller|
|Pow(base, exponent)||nth power|
Free Tips and Tricks for Using Cheatsheet MySQL Commands
- In the cheat sheet MySQL, if a list of all databases is required then use the command’ SHOW DATABASES;’ to get the available databases.
- The ‘CREATE DATABASE dbname;’ command is used to create a new database.
- To use the particular database, command ‘USE database;’ is used.
- The ‘SHOW TABLES;’ command needs to use the list of all tables in the MySQL database.
- ‘Describe table; Show Columns from a table;’ commands are used to show the structure of the table.
- ‘DROP DATABASE dbname;’ command is used to delete a database. Please be careful in using this command, after executing the rollback cannot be done.
- 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;
- 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;
- If there is forgot root password, use below commands:
$ /etc/init.d/mysql stop
$ mysqld_safe –skip-grant-tables &amp;
$ mysql # on another terminal
mysql> UPDATE mysql.user SET password=PASSWORD(‘[email protected]’) WHERE user=’root’;
$ /etc/init.d/mysql start
- If the table needs to repair after a shutdown is not proper:
mysqlcheck –all-databases –fast
- 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.
We hope that this EDUCBA information on “Cheat Sheet MySQL” was beneficial to you. You can view EDUCBA’s recommended articles for more information.