Installing MySQL 5.6 on Linux CentOS 6.2
What is MySQL ?
MySQL is an open source database management software that helps users store, organize, and retrieve data. It is a very powerful program with a lot of flexibility—this tutorial will provide the simplest introduction to MySQL
Now lets go ahead and see how we can install MySQL on a Linux machine.
Download MySQL rpm files from Oracle
website or from
MySQL Website .
We are going to use the MySQL 5.6.23 for Linux 64 bits in this installation example.
[ root@primary mysql_install]# pwd
/tmp/mysql_install
[ root@primary mysql_install]# unzip V74390-01.zip
Archive: V74390-01.zip
extracting: MySQL-client-advanced-5.6.23-1.el6.x86_64.rpm
extracting: MySQL-embedded-advanced-5.6.23-1.el6.x86_64.rpm
extracting: MySQL-server-advanced-5.6.23-1.el6.x86_64.rpm
extracting: MySQL-devel-advanced-5.6.23-1.el6.x86_64.rpm
extracting: MySQL-test-advanced-5.6.23-1.el6.x86_64.rpm
extracting: MySQL-shared-compat-advanced-5.6.23-1.el6.x86_64.rpm
extracting: MySQL-shared-advanced-5.6.23-1.el6.x86_64.rpm
extracting: README.txt
[ root@primary mysql_install]# ll
total 454836
-rw-r--r-- 1 root root 18658700 Jan 30 08:08 MySQL-client-advanced-5.6.23-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 3331064 Jan 30 08:08 MySQL-devel-advanced-5.6.23-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 88718056 Jan 30 08:08 MySQL-embedded-advanced-5.6.23-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 65170264 Jan 30 08:08 MySQL-server-advanced-5.6.23-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 2031628 Jan 30 08:08 MySQL-shared-advanced-5.6.23-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 3945168 Jan 30 08:08 MySQL-shared-compat-advanced-5.6.23-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 50999164 Jan 30 08:09 MySQL-test-advanced-5.6.23-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 11273 Feb 1 19:19 README.txt
-rw-r--r-- 1 root root 232866609 Mar 2 16:21 V74390-01.zip
[ root@primary mysql_install]# rpm -ihv MySQL-* rpm
Preparing... ########################################### [100%]
1:MySQL-devel-advanced ########################################### [ 14%]
2:MySQL-client-advanced ########################################### [ 29%]
3:MySQL-test-advanced ########################################### [ 43%]
4:MySQL-embedded-advanced########################################### [ 57%]
5:MySQL-shared-compat-adv########################################### [ 71%]
6:MySQL-shared-advanced ########################################### [ 86%]
7:MySQL-server-advanced ########################################### [100%]
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret' .
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test database.
This is strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file /usr/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap ( unless you used --defaults-file )
and when you later start the server.
The new default config file was created as /usr/my-new.cnf,
please compare it with your file and take the changes you need.
During the time the installer runs a password will be generated for you and will be stored inside the .mysql_secret file located in roots home directory.
[ root@primary ~]# cat .mysql_secret
# The random password set for the root user at Mon Mar 2 18:05:41 2015 (local time): yRzDLGZGwrjDI0vv
Also a my.cnf file will be created for you by the installer and is located at /usr/my.cnf .
-the my.cnf file is responsible for holding all your database configuration variables.
Here is the content of the sample my.cnf file, you can alter as you wish. Also there is a link inside the file pointing to MySQL website page that gives more details about configuration parameter.
[ root @ primary ~ ] # cat / usr / my . cnf
# For advice on how to change settings please see
# http : // dev . mysql . com / doc / refman / 5 . 6 / en / server - configuration - defaults . html
[ mysqld ]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL . Start at 70 % of total RAM for dedicated server , else 10 % .
# innodb_buffer_pool_size = 128 M
# Remove leading # to turn on a very important data integrity option : logging
# changes to the binary log between backups .
# log_bin
# These are commonly set , remove the # and set as required .
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers .
# The server defaults are faster for transactions and fast SELECTs .
# Adjust sizes as needed , experiment to find the optimal values .
# join_buffer_size = 128 M
# sort_buffer_size = 2 M
# read_rnd_buffer_size = 2 M
sql_mode = NO_ENGINE_SUBSTITUTION , STRICT_TRANS_TABLES
Now that we have our root password and we know where our my.cnf file is located let's start our MySQL service and log into our MySQL database
Start MySQL service
[ root @ primary ~ ] # / etc / init . d / mysql start
Starting MySQL . SUCCESS !
Log into the MySQL database using the password inside the .mysql_secret
[ root @ primary ~ ] # mysql - uroot - pyRzDLGZGwrjDI0vv
Warning : Using a password on the command line interface can be insecure .
Welcome to the MySQL monitor . Commands end with ; or g .
Your MySQL connection id is 1
Server version : 5 . 6 . 23 - enterprise - commercial - advanced
Copyright ( c ) 2000 , 2015 , 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
Next we need to alter the root password to fit our needs.
-for this example i will use the password 'root'.
mysql SET PASSWORD FOR 'root' @ 'localhost' = PASSWORD ( 'root' );
Query OK , 0 rows affected ( 0 . 00 sec )
mysql flush privileges ;
Query OK , 0 rows affected ( 0 . 00 sec )
mysql exit
Test the password
[ root @ primary ~ ] # mysql - uroot - proot
Warning : Using a password on the command line interface can be insecure .
Welcome to the MySQL monitor . Commands end with ; or g .
Your MySQL connection id is 2
Server version : 5 . 6 . 23 - enterprise - commercial - advanced MySQL Enterprise Server - Advanced Edition ( Commercial )
Copyright ( c ) 2000 , 2015 , 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
Great our MySQL database is up and running. This was a basic MySQL database installation using the default variables for installation, we will look into customized MySQL in future articles.