MySQL Database Points
- Introduction and use of Database
- Installation and Configuration
- To Login and exit from Database
- Data types explain
- Database Storage engines
A brief Introduction about MySQL database
A database is a collection of information so that it can easily be accessed, managed, and updated.
What is MySQL Database?
MySQL is an open source database management software that helps user to store, organize, and retrieve data. MySQL offers great reliability and easy to use and maintain the record in DB. Purpose of using database is to get rid the manual task into diary or other documentary. MySQL, pronounced either “My S-Q-L” or “My Sequel,” It is based on the structure query language (SQL). Standard MySQL commands, such as ADD, DROP, INSERT, and UPDATE can be used.
Install and Configure MySQL Database Server in CentOS/RHEL
Install the MySQL server package through the CentOS/RHEL repository.
[[email protected] ~]#yum install mysql mysql-server
Start Mysql Service.
[[email protected] ~]# service mysqld restart
Check MySQL service status
[[email protected] ~]# service mysqld status
Permanently on MySQL service on startup
[[email protected] ~]# chkconfig mysqld on
Identify on which ports MySQL work.
[[email protected] ~]# netstat -tunlp | grep mysqldtcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1657/mysqld
Setup MySQL root user password
[[email protected] ~]# mysqladmin -u root password [newpasswordhere]
Change/reset MySQL root password
[[email protected] ~]#mysqladmin -u root -p[oldpassword] password [newpass]
Setup MySQL database using mysql_secure_installation command
We recommend that you configure the following secure settings:
- Set a password for the MySQL root user.
- Remove MySQL anonymous users.
- Disallow remote login for the MySQL root user.
- The MySQL root user is allowed to connect to the database, but only from the local host.
- Remove the test database.
- Reload the Privileges table.
[[email protected] ~]# /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): (type password here if you already generate root password or hit enter if not )
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
You already have a root password set, so you can safely answer ‘n’.
Change the root password? [Y/n] y
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
Remove anonymous users? [Y/n] y
Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
By default, MySQL comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
– Dropping test database…
– Removing privileges on test database…
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Login into MySQL Database
[[email protected] ~]# mysql -u root –p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.1.73 Source distribution
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 respectiveowners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
Exit from MySQL database
[[email protected] ~]#
Note: After settings the mysql root password from bash sehll, clear the password history from .bash_history file
Shell/bash command history saved in
[[email protected] ~]# vim .bash_history
MySQL database queryhistory saved in
[[email protected] ~]# vim .mysql_history
MySQL Data type reference
TinyInt – A very small integer with a signed range of -128 to 127 and an unsigned range of 0 to 255 .
SmallInt – A small integer with a signed range of -32768 to 32767 and an unsigned range of 0 to 65535 .
MediumInt– A medium sized integer with a signed range of -8388608 to 8388607 and an unsigned range of 0 to 16777215 .
Int (Integer) – It can store 0 to 255 characters. holds a fixed length string (can contain letters, numbers, and special characters). The fixed size is specified in parenthesis.
Bigint– A large integer with a signed range of -9223372036854775808 to 9223372036854775807 and an unsigned range of 0 to 18446744073709551615.
VARCHAR(size) –It Holds a variable length string (letters, numbers, and special characters). The maximum size is specified in parenthesis. Can store up to 255 characters.
CHAR(size) – Holds a fixed length string (can contain letters, numbers, and special characters). The fixed size is specified in parenthesis. Can store up to 255 characters
Date and Time data type
DATETIME YYYY-MM-DD HH:MM:SS
Database Storage engines
- MEMORY (HEAP)
Differents between MyISAM and InnoDB.
MyISAM – This manages non transactional tables, provides high-speed storage and retrieval, supports full text searching.
InnoDB –It provides transaction-safe (ACID compliant) tables, supports FOREIGN KEY referential-integrity constraints. It supports commit, rollback, and crash-recovery capabilities to protect data.
This is all about basic concept of MySQL database server to perform some administration task, later we will post some useful MySQL command in our next tutorial.
CEO, KV IT-Solutions Pvt. Ltd. | [email protected] | 9810028374|
Linux Professional and an Industrial Trainer | 20 + years Experience in IT Industry
” We are born free, No Gate and Windows can snatch our freedom “