How to Install MySQL 5.6 on CentOS 6.3/RedHat EL6/Fedora

Standard

First head over here and download MySQL 5.6.14 rpm’s under Oracle & Redhat Linux 6 section of rpm’s.

You want to download these rpm’s to your CentOS 6 server [As we will install 64bit version on MySQL 5.6] :

  1. Red Hat/Oracle Enterprise Linux ver. 6 (x86, 64-bit), RPM Package – MySQL Server : MySQL-server-5.6.14-1.el6.x86_64.rpm
  2. Red Hat/Oracle Enterprise Linux ver. 6 (x86, 64-bit), RPM Package – Shared components : MySQL-shared-5.6.14-1.el6.x86_64.rpm
  3. Red Hat/Oracle Enterprise Linux ver. 6 (x86, 64-bit), RPM Package – Client Utilities : MySQL-client-5.6.14-1.el6.x86_64.rpm

To download on command line [Make sure that you have wget utility installed, if not install it :

yum install wget

Now download the rpm’s with wget utility:

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-shared-5.6.14-1.el6.x86_64.rpm/from/http://cdn.mysql.com/

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-client-5.6.14-1.el6.x86_64.rpm/from/http://cdn.mysql.com/

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-server-5.6.14-1.el6.x86_64.rpm/from/http://cdn.mysql.com/

Image 001

Now start installing rpms onto your server:

Make sure that Perl is installed on your server before you install MySQL, if not MySQL server rpm will complain that it cannot be installed. So its kind of pre-requisite.

Image 002

To Install perl run :

yum install perl

Image 003

Install MySQL 5.6 rpms now :

Start with shared libraries first and then work towards installing server and client utilities at the very end.

rpm -ivh MySQL-shared-5.6.14-1.el6.x86_64.rpm

rpm -ivh MySQL-server-5.6.14-1.el6.x86_64.rpm

rpm -ivh MySQL-client-5.6.14-1.el6.x86_64.rpm

If you have conflicts with existing libs(install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64), please download shared-compact package and do the following (Once complete, please re-install as stated above) :

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-shared-compat-5.6.14-1.el6.x86_64.rpm/from/http://cdn.mysql.com/
rpm -Uvh MySQL-shared-compat-5.6.10-1.el6.x86_64.rpm

Image 004

 

Image 005

 

On a successful install you should be seeing the log below:

 

MySQL Server Installation log:

 

Preparing… ########################################### [100%]

1:MySQL-server ########################################### [100%]

2013-02-08 14:59:19 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).

2013-02-08 14:59:19 2959 [Note] InnoDB: The InnoDB memory heap is disabled

2013-02-08 14:59:19 2959 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2013-02-08 14:59:19 2959 [Note] InnoDB: ………

2013-02-08 14:59:19 2959 [Note] InnoDB: ………

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 with the /usr/bin/mysqlbug script!

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.

 

Image 007

 Its all done, lets set some passwords, create user and grant access to outside clients for accessing the database:

 In MySQL 5.6 root has a default password assigned and its located at /root/.mysql_secret file as mention in MySQL server Installation log.

 Image 008

 cat that file :

cat /root/.mysql_secret

to get the password that has been set for MySQL default root user

Image 009

Now lets login to the database server for the first time and set password. That’s the only first SQL command that works before you can proceed any further. To do that we need to start our newly installed database server.

service mysql start

Image 010

Now login into database server using MySQL client utility and change password. To login into database server simply run command below and provide with the password that installation generated for you in /root/.mysql_secret file.

mysql -uroot -p

Image 011

Once you logged in, you have to change your root users default password. You cannot run any others commands.

Image 012

To change MySQL 5.6 database server root password simply run this command :

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('opensourcedbms');

Also there are other root users in MySQL if you are familiar with its users table [root@127.0.0.1 ; root@::1, root@hostname], once you login with superuser you can update all of them later. Also once all this is done you can remove /root/.mysql_secret file.

Image 013

Now that you have set root user password, create a super user to access database server from outside server. Its generally not a good practice to grant root user access to outside world.

CREATE USER 'superadmin'@'%' IDENTIFIED BY 'opensourcedbmsadmin';
GRANT ALL ON *.* TO 'superadmin'@'%' WITH GRANT OPTION;

Image 014

Now you can exit out of mysql command line client [Type \q or quit to exit] and we can use this newly created user to access this database server from outside world. Before you can do that, make sure that your server firewall rules are updated for granting this server to respond at port 3306 for outside world. First get out of the mysql command line client and to add a new firewall rule to your CentOS database server firewall rules and to do that edit

vi /etc/sysconfig/iptables

file and add the following line:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

Image 015

Save and exit out of the file and restart iptables for the new rule to take effect. To restart iptables, simply run the following command :

service iptables restart

Image 017

Last but not least make sure that this new MySQL server is enabled to auto start when server restarts.

chkconfig mysql --level 2345 on

Now you are ready to connect to this database server from any host in your network. Simply open a database client [MySQL Workbench / Navicat / SQLYog are few clients that you can use to access it from GUI side of things] that you installed and provide the new super user/password that you created and the host-name of this server and there you will be in your new database server.

mysql 5.5 sqlyog Image 015

If you are running this server in a virtual box environment, make sure that you do port forwarding (NAT Only) to pass through 3306 database port to guest VM which can be done by going to settings of your VM > Network > Advanced > Port forwarding. This is more specific to Oracle Virtual Box.

Image 018

facebooktwittergoogle_plusredditpinterestlinkedinmail

About Prashanth Goriparthi

Sr. Database Administrator / Architect

58 Comments

  1. Great tutorial, eased the installation of MySQL 5.6 on CentOS 6.3 basic server install, although one issue cropped up when installing the RPM’s.

    The following error: file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

    But the removing the mysql-libs fixed the issue

    rpm –nodeps -e mysql-libs

  2. Hi,

    I’m new to server administration and got the same error than andy :
    file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

    So i’ve tried to yum remove mysql-libs but got some packages depending on it :
    Dependencies Resolved

    =============================================================================================================================================================================================
    Package Arch Version Repository Size
    =============================================================================================================================================================================================
    Removing:
    mysql-libs x86_64 5.1.61-4.el6 @anaconda-CentOS-201207061011.x86_64/6.3 4.0 M
    Removing for dependencies:
    cronie x86_64 1.4.4-7.el6 @anaconda-CentOS-201207061011.x86_64/6.3 166 k
    cronie-anacron x86_64 1.4.4-7.el6 @anaconda-CentOS-201207061011.x86_64/6.3 43 k
    crontabs noarch 1.10-33.el6 @anaconda-CentOS-201207061011.x86_64/6.3 2.4 k
    postfix x86_64 2:2.6.6-2.2.el6_1 @anaconda-CentOS-201207061011.x86_64/6.3 9.7 M
    redhat-lsb x86_64 4.0-3.el6.centos @anaconda-CentOS-201207061011.x86_64/6.3 22 k
    sysstat x86_64 9.0.4-20.el6 @anaconda-CentOS-201207061011.x86_64/6.3 807 k

    Transaction Summary
    =============================================================================================================================================================================================
    Remove 7 Package(s)

    Installed size: 15 M

    What should i do ?

    Best regards,

      • great article!

        However the easiest way to solve the ‘mysql-libs’ issue is to install the ‘shared-compat’ RPM along with the ‘client’, ‘server’, and ‘shared’ RPM’s. For me, on a fresh install of centos 6.3 (with all yum updates as of 2013-02-16), this should replace ‘mysql-libs’.
        before:
        rpm -qa | grep -i mysql
        mysql-libs-5.1.67-1.el6_3.x86_64

        rpm -Uvh MySQL-shared-compat-5.6.10-1.el6.x86_64.rpm

        After:
        rpm -qa | grep -i mysql
        MySQL-shared-compat-5.6.10-1.el6.x86_64.rpm

  3. Pingback: How to setup replication with MySQL 5.6 Server on CentOS 6.3/Redhat EL6/Fedora

  4. Thank you very much for posting such a great and in depth article. Take pride in the people you have helped with this. -Fred

  5. Prashanth, if you want to avoid manual downloads using "wget" or building from source when installing MySQL 5.6, you can use PowerStack. It’s a open-source repository for CentOS (code is available on GitHub) with RPM packages for latest versions of LAMP stack (Apache 2.4, MySQL 5.6, PHP 5.4) and extra packages focused on server environment (memcached, nginx, HAproxy, node.js, etc.)

  6. I am following your approach but having troubles in mysql server installation… can please help me? what should I do? please help me….

    I am listing the error & logs:

    -bash-4.1$ sudo rpm -ivh /login/sg216750/softwaresinstallables/MYSQLServer\ For\ Linux/MySQL-shared-5.6.10-1.el6.x86_64.rpm
    Password:
    Preparing… ########################################### [100%]
    1:MySQL-shared ########################################### [100%]
    -bash-4.1$ ^C
    -bash-4.1$ sudo rpm -ivh /login/sg216750/softwaresinstallables/MYSQLServer\ For\ Linux/MySQL-server-5.6.10-1.el6.x86_64.rpm
    Password:
    Preparing… ########################################### [100%]
    file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64
    file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.6.10-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

  7. I am at root directory, having troubles to install the MySQL db…
    can someone pls help me:

    Error log:
    -bash-4.1$ sudo rpm -ivh /login/sg216750/softwaresinstallables/MYSQLServer\ For\ Linux/MySQL-shared-5.6.10-1.el6.x86_64.rpm
    Preparing… ########################################### [100%]
    1:MySQL-shared ########################################### [100%]
    -bash-4.1$ sudo rpm -ivh /login/sg216750/softwaresinstallables/MYSQLServer\ For\ Linux/MySQL-server-5.6.10-1.el6.x86_64.rpm
    Preparing… ########################################### [100%]
    1:MySQL-server ########################################### [100%]
    ERROR: can’t create /login/sg216750/.mysql_secret: Permission denied at /usr/bin /mysql_install_db line 306.

  8. Couple of issues:

    If running mysql 5.1, of course the command to stop the server would be:

    service mysqld stop

    An issue I ran in to (not sure why), is that everything went great with the upgrade to the point of setting/resetting the temporary password. I’m not sure exactly what the problem was, but this is what mysql told me:

    ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol refused (client option ‘secure_auth’ enabled)

    I simply started MySQL without a password, reset it manually, then everything was ready to roll with your next step. To reset manually, this is what I needed to do:
    # service mysql stop
    Shutting down MySQL.. SUCCESS!
    # service mysql start –skip-grant-tables
    Starting MySQL. SUCCESS!
    # mysql
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 1
    Server version: 5.6.11 MySQL Community Server (GPL)

    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> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A

    Database changed
    mysql> update user set password=PASSWORD("Put-Real-Password-Here") where User="root";
    Query OK, 4 rows affected (0.03 sec)
    Rows matched: 4 Changed: 4 Warnings: 0

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    mysql> quit
    Bye
    # service mysql start
    Starting MySQL. SUCCESS!

    After that I was able to pick up again with mysql_upgrade.

    Hope that helps anyone else that may run in to the same issue.

    Thanks for the article…my server is happily humming along with MySQL 5.6 now; looking forward to the new and improved replication!

    – Paul Rupp
    Acorp Computers

  9. Hi Prashanth,
    I went thru with your doc and i was able to do it.
    I have a problem,Please help me in knowing that.
    My Mysql server is up and running, i have forgotten the mysql root password.Is their any way to fetch that.

    Please help me,
    Thanks in advance,
    Nandan

    • Hey Nandan,

      1. Create a file under your temp directory and call it resetpass with the following contents:

      UPDATE mysql.user SET Password=PASSWORD(‘newpassword’) WHERE User=’root';
      FLUSH PRIVILEGES;

      2. Start MySQL with this file as init script.

      mysqld_safe –init-file=/tmp/resetpass &

      After mysql starts, remove the resetpass file and you should be able to use your new password to get in.

      Let me know if you have any issues getting in.

  10. Please excuse as am pretty much a newb on terminal linux.

    1) Is it best security practice to be logged in & install MySQL with a lower privileged ‘mysql’ login (operating system account) instead of being logged in & installing as ‘root’ login (operating system account) and if yes what are the steps in how to do that?

    2) Is there a certain folder location MySQL installation should or need to specifiy or does the above steps automatically installs everything in their proper locations by default?

    • Before installing mysql you will not have mysql user at OS level unless you create. Installing it as root user doesn’t harm and is not a bad practice. You can leave data directories in default locations or move it to a separate mount points depending on how you laid out your partition scheme. In general you don’t have to change default location.

  11. I was having the same problem with the file conflicts – rpm -Uvh MySQL-shared-compat-5.6.11-1.el6.x86_64.rpm saved teh day.

    THANK YOU!

  12. I try to install MySQL 5.6 with your instruction but I found a problem when I install mytop.

    When I install about DBD::mysql in perl module. It’s had an error Like

    I use CentOS 6.4 x86_64

    You can also optionally set the user to run 'make test' with:

    perl Makefile.PL --testuser=username

    Can't exec "mysql_config": No such file or directory at Makefile.PL line 479.
    Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
    Can't exec "mysql_config": No such file or directory at Makefile.PL line 479.
    Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
    Can't exec "mysql_config": No such file or directory at Makefile.PL line 479.
    Can't find mysql_config. Use --mysql_config option to specify where mysql_config is located
    Failed to determine directory of mysql.h. Use

    perl Makefile.PL --cflags=-I

    to set this directory. For details see the INSTALL.html file,
    section "C Compiler flags" or type

    perl Makefile.PL --help
    Warning: No success on command[/usr/bin/perl Makefile.PL INSTALLDIRS=site]
    Warning (usually harmless): 'YAML' not installed, will not store persistent state
    CAPTTOFU/DBD-mysql-4.023.tar.gz
    /usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
    Running make test
    Make had some problems, won't test
    Running make install
    Make had some problems, won't install
    Could not read '/root/.cpan/build/DBD-mysql-4.023-mw7CqM/META.yml'. Falling back to other methods to determine prerequisites
    Failed during this command:
    CAPTTOFU/DBD-mysql-4.023.tar.gz : writemakefile NO '/usr/bin/perl Makefile.PL INSTALLDIRS=site' returned status 512

    How should I do ?

  13. Pingback: How to enable pdo_mysql with mysql 5.6 from binaries | Life with Linux

  14. Pingback: Send data from android application to a server : Android Community - For Application Development

  15. GR8 tut.. as per the instruction given above i have configured MySQL 5.6 in RHEL 5, but after changing the password as given above to PASSWORD, i m unable to enter in to mysql > promt. it gives me error message: ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
    what can be the reason.
    Also what will be the password for superadmin user which has been created as above.
    Pls give me solution.
    Thanks in advance.

    • superadmin has opensourcedbmsadmin as password. If you reset the password properly you should be able to login. Try resetting it.

  16. Pingback: How to Install MySQL 5.6 on CentOS 6.3/RedHat EL6/Fedora | micanzhang 's blog

  17. Great guide thanks a lot. But, I can’t start MySQL service normally. It conflicts with SELinux policy. But I can run it by changing the policy to "permissive". But it looks like you didn’t touched the SELinux part. How did you do that?

  18. hi prashanth,
    u said that before mysql installtion we need to install perl packages, can you please share me what are the perl packages i need to install, to install mysql. am using RHEL-6

  19. Thank you very much Prashanth and Excellent job..!!

    I’m using Centos 6.5 and install followings with helping your tutorial

    1)MySQL-shared-5.6.15-1.el6.x86_64.rpm

    2)MySQL-server-5.6.15-1.el6.x86_64.rpm

    3)MySQL-client-5.6.15-1.el6.x86_64.rpm

    with,
    MySQL-shared-compat-5.6.15-1.linux_glibc2.5.x86_64.rpm.

    Seem like no errors yet and working fine.

    is it ok to use glibc or is there a way to change my libraries to MySQL-shared-compat-5.6.15-1.el6.x86_64.rpm ?

    because of when I try to install el6 it says already installed newer version as well as I cannot uninstall first because of there are some dependencies on libraries.

  20. Pingback: MySQL configuration specific to Cent OS | SZemtsov Technical Roll

  21. great tutorial

    i do have a problem though. centos says mysql 5.6.13 (common – Server- Client) installed but phpmyadmin says client is version 5.0.11???

  22. from where can i download mysql packages for 32bit rhel6… i tried google but unable to grab….pls share the link if u know

  23. Nice post!

    Any change of configuring it on high availability pacemaker+corosync+iscsi cluster environment?

    that would be a great help!
    thank you!

  24. Pingback: 이음만을 위한 하루 – 개발환경 정비

Leave a Reply


4 × seven =