Today in this article, we will show you some basic MySQL commands for DBA which will be helpful in your daily basis tasks.
Table of Contents
1. MySQL stop/start/status Command :
- systemctl stop mysqld
- systemctl start mysqld
- systemctl status mysqld
2. MySQL Database/tables Check :
- show databases
- show tables
3. Create/Open/Drop database :
- create database database_name
- use database_name
- drop database database_name
4. Create/select/Drop Table :
CREATE TABLE test1 (
ID int,
Name varchar(255),
Address varchar(255),
register_date DATETIME,
Primary key (ID)
);
- insert into test1 values(1,’john’,’NY’,now());
- insert into test1 values(2,’harry’,’NY’,now());
- show tables;
- select * from table_name;
- drop table table_name;
- truncate table table_name;
- describe table_name;
- delete from table_name;
5. Create/connect/drop User :
- mysql -u [username] -p;
- mysql -u [username] -p [database];
- mysqladmin -u root password root_password;
- create user username@localhost;
- create user username@localhost identified by password;
- select user,host from mysql.user;
- drop user username@localhost;
In a nutshell, you can go through the Commands as above. Hope this helps. Also you can check the article for another reference.
For detailed MySQL installation/DBA stuffs, you can follow our another article.