In this tutorial we will learn, how to install MySQL Server 5.6 on CentOS 7 / RHEL 7 . In our previous post, we have installed MySQL Server 5.6 on CentOS 6.x/RHEL 7.x.
In CentOS 7/ RHEL 7 , now MariaDB is introduced as a defualt database. Still many Organisations/Company would like to continue with MySQL. Whereas System Admin who earlier worked on MySQL can easily work on MariaDB. MariaDB is a community-developed fork of the MySQL relational database management system.
MariaDB’s lead developer is Michael “Monty” Widenius, the founder of MySQL and Monty Program AB. He had previously sold his company, MySQL AB, to Sun Microsystems for US$1 billion. MariaDB is named after Monty’s younger daughter, Maria. (Reference taken from Wikipedia)
Install MySQL Server 5.6 on CentOS 7 / RHEL 7
Follow the given below steps to install MySQL Server 5.6 .
You must be login with root user in system
Download the Yum Repo package of MySQL Server 5.6
Download the rpm package, which will create a yum repo file for MySQL Server installation.
yum install wget
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Install mysql-community-release-el7-5.noarch.rpm package
Install this downloaded rpm package by using rpm command.
rpm -ivh mysql-community-release-el7-5.noarch.rpm
After the installation of this package. We will get two new yum repo related to MySQL
[root@localhost ~]# ls -1 /etc/yum.repos.d/mysql-community* /etc/yum.repos.d/mysql-community.repo /etc/yum.repos.d/mysql-community-source.repo [root@localhost ~]#
Installing MySQL Server
By using yum command, now we will install MySQL Server 5.6 . All dependencies will be installed itself.
yum install mysql-server
How to start/stop/restart MySQL Server
Now MySQL Server is installed on your system.
To start MySQL Service, run command
systemctl start mysqld
To stop MySQL Service, run command
systemctl stop mysqld
To restart MySQL Service, run command
systemctl restart mysqld
To get status of MySQL Service, run command
systemctl status mysqld
Reset MySQL root password
On fresh installation of MySQL Server. The MySQL root user password is blank.
For good security practice, we should reset the password MySQL root user.
On newly installed MySQL Server, we generally recommend to use the command script. You have to just follow the instructions.
mysql_secure_installation
In another method,you can log into MySQL server database and reset the password in secure way.
mysql -u root
You will see mysql prompt like this mysql> . Use the below given commands to reset root’s password.
mysql> use mysql;
mysql> update user set password=PASSWORD("GIVE-NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit


Thanks! Help me a lot.!! 😀
Hello Alice,
Glad to see good feedback on this post.
Keep reading our blog.
Regards
Sharad
Thanks. Help me a lot.
Thanks Marcelo,
Regards
Sharad
i need your assistance on centos 7:
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
it goes:
Resolving repo.mysql.com (repo.mysql.com) … 23.15.144.142 … connected .HTTP request sent, awaiting response … 404 not found [date, time] ERROR 404: Not Found
i’ve tried suggestions from this site: http://stackoverflow.com/questions/7623698/wget-cant-download-404-error/32323255#32323255 i’ve tried the (–header), the (“) quotes, the IPv4 (-4)
but i still get the error 404
Hi VariaS,
Is your network behind the proxy. I checked from my end , it is working fine for me.
Best Regards
Sharad
Thank you, this was very helpful.
You are welcome Tom,
Best Regards
Sharad
How to install MySQL-server-community-5.0.51a-0.rhel4.i386.rpm
on Centos 7 please update if there is a way
thanks
Hello Wahi,
Require following details, so that I can help you –
1. Operating System : ?
2. Arch : ?
Regards
Sharad
Thanks @sharad (sorry about bad english)
in advance i have a centos 7 and i want to install mysql offline using package MySQL-5.6.24-1.el7.x86_64.rpm-bundle which is related to redhat 7- 64 bit from website (https://dev.mysql.com/downloads/mysql/)
when i download it and install it by using command rpm
rpm -ivh MySQL-client-5.6.24-1.el7.x86_64.rpm
rpm -ivh MySQL-devel-5.6.24-1.el7.x86_64.rpm
rpm -ivh MySQL-embedded-5.6.24-1.el7.x86_64.rpm
rpm -ivh MySQL-shared-5.6.24-1.el7.x86_64.rpm
rpm -ivh MySQL-server-5.6.24-1.el7.x86_64.rpm
1) frist error is this
file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.24-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64
1-Solution) i have solved it using
rpm -evh mariadb-libs-5.5.41-2.el7_0.x86_64 –nodeps
Thanks @sharad (sorry about bad english) (sorry my replay will be many replies becuase it is very long )
in advance i have a centos 7 and i want to install mysql offline using package MySQL-5.6.24-1.el7.x86_64.rpm-bundle which is related to redhat 7- 64 bit from website (https://dev.mysql.com/downloads/mysql/)
when i download it and install it by using command rpm
rpm -ivh MySQL-client-5.6.24-1.el7.x86_64.rpm
rpm -ivh MySQL-devel-5.6.24-1.el7.x86_64.rpm
rpm -ivh MySQL-embedded-5.6.24-1.el7.x86_64.rpm
rpm -ivh MySQL-shared-5.6.24-1.el7.x86_64.rpm
rpm -ivh MySQL-server-5.6.24-1.el7.x86_64.rpm
1) frist error is this
file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.24-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64
1-Solution) i have solved it using
rpm -evh mariadb-libs-5.5.41-2.el7_0.x86_64 –nodeps
i need a tutorial to install mysql using offline method without yum with rpm
because i have not Internet connection to server
please help me ???
i have download MySQL-5.6.24-1.el7.x86_64.rpm-bundle from mysql website but i get errors during installation
Sure Beshoy, I will help you. Let’s discuss here in comments section. Share the error which you are getting.
Regards
Sharad
1) when i enter a blank password with command /usr/bin/mysql_secure_installation
give me error . i run mysqld_safe –skip-grant-tables & –> but not solve problem
and i did not enter any password ???
2) second question : i have select mysql for redhat 7 is it compatible with centos 7 or i must select linux version instead ?????
3) third question : mysql user was created using id 992 by checking /etc/passwd
mysql:x:992:990:MySQL server:/var/lib/mysql:/bin/bash
is this will make problem in future as the id=992 is not root privilege and i must be below 500 ?????
1) when i enter a blank password with command /usr/bin/mysql_secure_installation
give me error . i have run mysqld_safe –skip-grant-tables &
to solve it but i can not -> still i want a solution to this problem ????
2) second question : i have select mysql for redhat 7 is it compatible with centos 7 or i must select linux version instead ?????
3) third question : mysql user was created using id 992 by checking /etc/passwd
mysql:x:992:990:MySQL server:/var/lib/mysql:/bin/bash
is this will make problem in future as the id=992 is not root privilege and i must be below 500 ?????
4) did i select the correct package(MySQL-5.6.24-1.el7.x86_64.rpm-bundle.tar) or it not the correct package to installed on centos 7 ?????
I tried to install mysql server in centos 7.It got installed successfully.
When i tried to access mysql via mysql-u root ,I got below error.
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
Below is my log file:
2015-02-18 17:55:51 35161 [Note] InnoDB: Highest supported file format is Barracuda.
2015-02-18 17:55:52 35161 [Note] InnoDB: 128 rollback segment(s) are active.
2015-02-18 17:55:52 35161 [Note] InnoDB: Waiting for purge to start
2015-02-18 17:55:52 35161 [Note] InnoDB: 5.6.23 started; log sequence number 1600627
2015-02-18 17:55:52 35161 [Note] Server hostname (bind-address): ‘*’; port: 3306
2015-02-18 17:55:52 35161 [Note] IPv6 is available.
2015-02-18 17:55:52 35161 [Note] – ‘::’ resolves to ‘::’;
2015-02-18 17:55:52 35161 [Note] Server socket created on IP: ‘::’.
2015-02-18 17:55:52 35161 [ERROR] Fatal error: Can’t open and lock privilege tables: Table ‘mysql.user’ doesn’t exist
150218 17:55:52 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
When i enter “systemctl status mysql.service” it show below
mysqld.service – MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: activating (start-post) since Wed 2015-02-18 17:45:51 EST; 7min ago
Process: 32975 ExecStart=/usr/bin/mysqld_safe (code=exited, status=0/SUCCESS)
Process: 32965 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 32975 (code=exited, status=0/SUCCESS); : 32976 (mysql-systemd-s)
CGroup: /system.slice/mysqld.service
└─control
├─32976 /bin/bash /usr/bin/mysql-systemd-start post
└─34615 sleep 1
Feb 18 17:45:51 localhost.localdomain systemd[1]: mysqld.service holdoff time over, scheduling restart.
Feb 18 17:45:51 localhost.localdomain systemd[1]: Stopping MySQL Community Server…
Feb 18 17:45:51 localhost.localdomain systemd[1]: Starting MySQL Community Server…
Feb 18 17:45:51 localhost.localdomain mysqld_safe[32975]: 150218 17:45:51 mysqld_safe Logging to ‘/var/log/mysqld.log’.
Feb 18 17:45:51 localhost.localdomain mysqld_safe[32975]: 150218 17:45:51 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Feb 18 17:45:52 localhost.localdomain mysqld_safe[32975]: 150218 17:45:52 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
I dont think my sql is running ..
Please let me know how to make sql running.
When i enter “systemctl start mysqld.service” nothing is happeing, it remains blank for a long time.
I need to press ctrl+c to break it..
The following command made it work:
mysql_install_db –-user=mysql –ldata=/var/lib/mysql
(see http://stackoverflow.com/questions/9083408/fatal-error-cant-open-and-lock-privilege-tables-table-mysql-host-doesnt-ex)
Thankyou Reinhold,
Happy to see your feedback, it is helpful.
Regards
Sharad
Great tutorial, only one thing, to avoid the “[Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)” after start the server, its necessary to add
LimitNOFILE=65535
LimitNPROC=65535
at the end of the file /usr/lib/systemd/system/mysqld.service
and then execute:
systemctl daemon-reload
Hi,
unfortunately the server doesn’t start
I’m very grateful for any help.
mysqld.service – MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: activating (start-post) since Wed 2015-01-21 11:34:04 CET; 41s ago
Process: 21737 ExecStart=/usr/bin/mysqld_safe (code=exited, status=0/SUCCESS)
Process: 21726 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 21737 (code=exited, status=0/SUCCESS); : 21738 (mysql-systemd-s)
CGroup: /system.slice/mysqld.service
└─control
├─21738 /bin/bash /usr/bin/mysql-systemd-start post
└─22043 sleep 1
Jan 21 11:34:04 systemd[1]: Starting MySQL Community Server…
Jan 21 11:34:04 mysqld_safe[21737]: 150121 11:34:04 mysqld_safe Logging to ‘/var/log/mysqld.log’.
Jan 21 11:34:04 mysqld_safe[21737]: 150121 11:34:04 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jan 21 11:34:05 mysqld_safe[21737]: 150121 11:34:05 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Hello Reinhold,
Can you check the /var/log/messages and mysql logs.
Regards
Sharad
Thanks, Sharad! It seems to be some permission problem.
/var/log/mysqld.log:
2015-01-21 12:14:05 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
2015-01-21 12:14:05 30002 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2015-01-21 12:14:05 30002 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000)
2015-01-21 12:14:05 30002 [Note] Plugin ‘FEDERATED’ is disabled.
/usr/sbin/mysqld: Can’t find file: ‘./mysql/plugin.frm’ (errno: 13 – Permission denied)
2015-01-21 12:14:05 30002 [ERROR] Can’t open the mysql.plugin table. Please run mysql_upgrade to create it.
2015-01-21 12:14:05 30002 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-01-21 12:14:05 30002 [Note] InnoDB: The InnoDB memory heap is disabled
2015-01-21 12:14:05 30002 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-01-21 12:14:05 30002 [Note] InnoDB: Memory barrier is not used
2015-01-21 12:14:05 30002 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-01-21 12:14:05 30002 [Note] InnoDB: Using Linux native AIO
2015-01-21 12:14:05 30002 [Note] InnoDB: Using CPU crc32 instructions
2015-01-21 12:14:05 30002 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-01-21 12:14:05 30002 [Note] InnoDB: Completed initialization of buffer pool
2015-01-21 12:14:05 30002 [Note] InnoDB: Highest supported file format is Barracuda.
2015-01-21 12:14:05 7fc62d999740 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2015-01-21 12:14:05 30002 [ERROR] InnoDB: Could not find a valid tablespace file for ‘mysql/innodb_index_stats’. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2015-01-21 12:14:05 30002 [ERROR] InnoDB: Tablespace open failed for ‘”mysql”.”innodb_index_stats”‘, ignored.
2015-01-21 12:14:05 7fc62d999740 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2015-01-21 12:14:05 30002 [ERROR] InnoDB: Could not find a valid tablespace file for ‘mysql/innodb_table_stats’. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2015-01-21 12:14:05 30002 [ERROR] InnoDB: Tablespace open failed for ‘”mysql”.”innodb_table_stats”‘, ignored.
2015-01-21 12:14:05 7fc62d999740 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2015-01-21 12:14:05 30002 [ERROR] InnoDB: Could not find a valid tablespace file for ‘mysql/slave_master_info’. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2015-01-21 12:14:05 30002 [ERROR] InnoDB: Tablespace open failed for ‘”mysql”.”slave_master_info”‘, ignored.
2015-01-21 12:14:05 7fc62d999740 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2015-01-21 12:14:05 30002 [ERROR] InnoDB: Could not find a valid tablespace file for ‘mysql/slave_relay_log_info’. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2015-01-21 12:14:05 30002 [ERROR] InnoDB: Tablespace open failed for ‘”mysql”.”slave_relay_log_info”‘, ignored.
2015-01-21 12:14:05 7fc62d999740 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2015-01-21 12:14:05 30002 [ERROR] InnoDB: Could not find a valid tablespace file for ‘mysql/slave_worker_info’. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2015-01-21 12:14:05 30002 [ERROR] InnoDB: Tablespace open failed for ‘”mysql”.”slave_worker_info”‘, ignored.
2015-01-21 12:14:05 30002 [Note] InnoDB: 128 rollback segment(s) are active.
2015-01-21 12:14:05 30002 [Note] InnoDB: Waiting for purge to start
2015-01-21 12:14:05 30002 [Note] InnoDB: 5.6.22 started; log sequence number 1626007
2015-01-21 12:14:05 30002 [Note] Server hostname (bind-address): ‘*’; port: 3306
2015-01-21 12:14:05 30002 [Note] IPv6 is available.
2015-01-21 12:14:05 30002 [Note] – ‘::’ resolves to ‘::’;
2015-01-21 12:14:05 30002 [Note] Server socket created on IP: ‘::’.
2015-01-21 12:14:05 30002 [ERROR] /usr/sbin/mysqld: Can’t find file: ‘./mysql/user.frm’ (errno: 13 – Permission denied)
2015-01-21 12:14:05 30002 [ERROR] Fatal error: Can’t open and lock privilege tables: Can’t find file: ‘./mysql/user.frm’ (errno: 13 – Permission denied)
150121 12:14:05 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
mysql_upgrade fails:
Looking for ‘mysql’ as: mysql
Looking for ‘mysqlcheck’ as: mysqlcheck
FATAL ERROR: Upgrade failed
Thank you so much;
Your Welcome Freed,
Regards
Sharad
So clean and simple
Thankyou Ram,
Regards
Sharad
Sharad,
I am bit new to setup mysql server. I have fresh installed mysql-community-server 5.6.21. I am looking inside my.cnf file. Can you help me out to know either my installation is perfect or there are some thing change. and how to set configuration parameters.
Regards
Mashkoor
Hello Mashkoor,
I am happy to help you. Send the my.cnf file attached to email at admin@sharadchhetri.com .
Regards
Sharad
thanks Sharad,
It find the my.cnf file in /etc/ but it’s not the same like other centos version such as my.cnf is different in centos 6.5 or 6.4 and also there are some other .ini file with in the mysql installation but here it’s totaly changed didn’t find any .ini,and innodb and my.cnf is also change. If i look for the running process it runs with “/usr/bin/mysqld-safe” is installed package fine. or I should re-install it again with different repository.
Kind & Regards
Mashkoor Qadir
Hello Mashkoor,
Have you upgraded the MySQL from previous version or freshly installed.
Whereas in MySQL 5.6 new parameters have introduced. I need some clear question, where you are trying to find innodb. It is a engine.
Regards
Sharad
Regards
Sharad
thanks for your hardworking but i am bit confused about the my.cnf file and innodb. I didn’t find any where after the successful installation
Hello Mashkoor,
Login as root.
The path is /etc/my.cnf .
If still did not find the my.cnf file . Run the below given command
Regards
Sharad
Thanks !
Welcome, A,Torres.
Thanks again, have a good day and a great day at work