MYSQL Command Line Tutorial – Kali Linux

As you all knows, Kali Linux is one of the most popular penetration testing operating system having more than 400+ hacking tools pre-installed in it.

Kali is the latest and greatest version of the ever popular Backtrack Linux penetration testing distribution. The creators of the Backtrack series kept Kali in a format very similar to Backtrack, so anyone familiar with the older Backtrack platform will feel right at home.

Kali has been re-vamped from the ground up to be the best and most feature rich Ethical Hacking/Pentesting distribution available. Kali also runs on more hardware devices greatly increasing your options for computer security penetration testing or “pentesting” systems.

If you are coming to Kali from a Backtrack background, after a short familiarization period you should find that everything is very similar and your comfort level should grow very quickly.

If you are new to Kali, once you get used to it, you will find an easy to use security testing platform that includes hundreds of useful and powerful tools to test and help secure your network systems.

Before to use MySQL command line interface, make sure that your MySQL service must be in active or running state, and to start the MySQL service in Kali Linux, type “service mysql start” and to check the status of your mysql service, type “service mysql status“.

MySQL or MariaDB, both are same in Kali Linux so don’t get confuse by the name, In MariaDB, you can run all MySQL commands in efficient manner.

To login into MySQL from a Unix Shell, type “mysql -h localhost -u root -p” and press double enter because by default there is no password set for user root in MySQL.

Now to create a new database, type “create database <DB Name>;” and to show all databases, type “show databases;” in same console.

If you want to switch the database, then you can type “use <DB Name>;

To create table via command line, type “CREATE TABLE <table name> (id VARCHAR(20), firstname VARCHAR(20), lastname VARCHAR(20), username VARCHAR(8), email VARCHAR(35), password VARCHAR(25));

and to show all tables, you can type “show tables“.

To Insert any data, you can type “INSERT into <table name> (id, firstname, lastname, username, email, password) VALUES (‘1’, ‘Yeah’, ‘Hub’, ‘yeahhub’, ‘’, ‘123456’);

To see database’s field formats, type “describe <table name>;

To see all the data in a particular table, you can type “SELECT * FROM <table name>;

And if you want to show the data of a particular column, then the command is “SELECT <column name> FROM <table name>;

To count the number of rows of a particular table, type “SELECT COUNT(*) FROM <table name>;

If you want to create a new user in MySQL database, then you’ve to switch the database to MySQL first by typing “use mysql;” in same console.

Then type “INSERT INTO user (Host,User,Password) VALUES(‘%’,’username’,PASSWORD(‘password’));

And to update the database permissions/privileges, type “flush privileges;

To delete any row from a particular table, type “DELETE from <table name> where <field name> = ‘whatever’;

And if you want to delete the whole table, then the command is “drop table <table name>;

You may also like:

Sarcastic Writer

Step by step hacking tutorials about wireless cracking, kali linux, metasploit, ethical hacking, seo tips and tricks, malware analysis and scanning.

Related Posts