• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Beginners 4 basic commands of database in mysql server

August 9, 2013 by Sharad Chhetri Leave a Comment

Today we will learn about 4 basic commands in mysql server which are related to manage the database.These 4 commands are important for any Mysql Database administrator.The post is mainly written for beginners of MySQL database administration.
All the data are saved in some database. These Databases have some name hence the basic thing is,we should know how can we create,drop(remove),show or connect to databases in MySQL server.

MySQL Server Version : 5.5.31

First login in MySQL server

MySQL root user has all privileges and it is by defualt administrator in MySQL Server.
We will do all the practical by using mysql user root. You can also replace username root with your mysql user but it must have privileges to create,drop,rename and show databases

First login into the mysql server by using below given syntax.

mysql -u username -p 

See my below reference ,how it looks after login into server.It will give mysql prompt (mysql>.Here I have login with user root)

root@debian:~# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 160
Server version: 5.5.31-0+wheezy1 (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>

How to show databases in mysql server

To show number of databases exist in mysql server use the below given command in mysql prompt.

show databases;

Given below is the reference of my system

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| owncloud           |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)

mysql>

How to create database in MySQL server

To create a database in MySQL server use the below given command

create database database-name;

Given below is the reference of my system.
Note: I used show databases; to see new database name linux in database list.

mysql> 
mysql> create database linux;
Query OK, 1 row affected (0.00 sec)

mysql> 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| linux              |
| mysql              |
| owncloud           |
| performance_schema |
+--------------------+
5 rows in set (0.00 sec)

mysql> 

How to remove or drop database in mysql server

To drop the database in mysql server use the below given command

drop database database-name

See the below given reference of my system

mysql> drop database linux;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| owncloud           |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)

mysql> 

How to connect to database or use database in MySQL server

To connect to database or use the database, follow the given below command

use database-name

Note: To know which database you are using currently,follow the given below command.

select database();


Below is the reference of above given two commands from my system

mysql> use linux;
Database changed
mysql> 
mysql> select database();
+------------+
| database() |
+------------+
| linux      |
+------------+
1 row in set (0.00 sec)

mysql> 

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Find mysql commands history without mysql server login
  2. postgres database backup script using database user password inside
  3. create noreply email id in postfixadmin mysql database
  4. Linux Basic Commands With Examples For Every Beginner
  5. hash:/etc/postfix/virtual is unavailable. open database /etc/postfix/virtual.db: No such file or directory
  6. Yum Error database disk image is malformed
  7. How to install mysql server in RedHat and CentOS
  8. Set delay replication to MySQL slave server
  9. How to install mysql server 5.6 on Ubuntu 14.04 LTS ( Trusty Tahr )
  10. How to install MySQL Server 5.6 on CentOS 7 / RHEL 7

Filed Under: mysql Tagged With: mysql

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

configure: error: C++ compiler cannot create executables

Virtual Machine inaccessible status on VirtualBox 4.3

Read the file inside compressed .gz files without extract

How To Get SSH Public Key Fingerprint Information

fatal error: error writing to /tmp/ccwAjc9Z.s: No space left on device

How to zip the directory in linux with command line

curl command to check the http status

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy