Google+

Sunday 26 April 2015

MySQL basic commands

Learn some basic commands for world's most popular MySQL database.

mysql -u [username] -p: This command is used to log in to a MySQL server using a specific username and password.

SHOW DATABASES;: This command displays a list of all the databases on the MySQL server.



USE [database_name];: This command is used to select a specific database to work with.

SHOW TABLES;: This command displays a list of all the tables in the currently selected database.

DESCRIBE [table_name];: This command is used to display the structure of a specific table, including the column names and data types.

SELECT * FROM [table_name];: This command is used to retrieve all the data from a specific table.

INSERT INTO [table_name] (column1, column2, column3) VALUES (value1, value2, value3);: This command is used to insert new data into a specific table.

UPDATE [table_name] SET column1 = new_value WHERE some_column = some_value;: This command is used to update existing data in a specific table.

DELETE FROM [table_name] WHERE some_column = some_value;: This command is used to delete data from a specific table.

EXIT;: This command is used to exit the MySQL prompt and return to the command line.

It's important to note that these commands should be used with caution, as some of them can have a significant impact on the data stored in the database.




mysql-basics