Can't install mysql on CentOS 7

July 12, 2014 141.8k views

It just says no package mysql-server available. I've tried every tutorial, egel and whatnot installed. It's not on the list of things that are not supposed to be installed. Is there a way to force install it from somewhere that's not from the fastest mirrors so I can see if the mirrors just aren't working?

edit - I can install mysql-devel, just not anything else.

10 Answers

Don't forget to set it up as a service. This is from the tutorial @Omar posted.

sudo yum -y install mariadb-server mariadb
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Once you do that, you should be able to run the mysql command and it will just let you in.

[vagrant@default ~]$ mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [(none)]> 

So... you'll probably want to secure it:


MariaDB is shipped in the CentOS repo as of CentOS 7 instead of mysql.
if you still want to install mysql you need to add mysql rpm dependency into your yum repo.

check this tutorial out of how to install mysql 5.6 in CentOS7 :

How to install latest mysql 5.6 on CentOS7

Not 100%, sure if this is true in your case but there may not be a package yet. CentOS 7 is only been out for a few days and they changed some of the inner workings in this version. If you are hosting everything on one server (web app & database), I would recommend using CentOS 6.5 now and keep an eye on 7 until package managers catch up to the new release and at that time deploy a CentOS 7 server and rsync all your files over. There also is an upgrade tool to upgrade 6.5 to 7 in the works, you also could take that action. (I would not recommend this, as there could be downtime. When the time comes I would build the CentOS 7 server and transfer everything over. This would mean 5 - 10 minutes downtime if done properly.

I'm pretty sure that mysql has been replaced by MariaDB.

Right. CentOS 7 (as well as RHEL 7) does not include MySQL. It instead ships MariaDB which a drop in replacement. You can install it with:

sudo yum install mariadb-server mariadb

Can I migrate MySQL database to Maria DB?

Is it transparent?

  • Yes, MariaDB is a drop-in replacement for MySQL. Simply uninstall MySQL (make sure you do not purge your configuration files or /var/lib/mysql) and install MariaDB.

  • but why do people are shifting to mariadb ? mysql is now owned by oracle but still it is open source .

  • @adityabayana Different people will give you different reasons. Some don't believe that Oracle is a good steward of the open source project. In fact, the original creator of MySql is involved with the MariaDB project.

Yes the title is wrong. This is for mariadb which is already installed.
I tried adding the yum repository as noted by rparker above ( rpm -Uvh ... ) but that failed dependency checks without any detail error messages on cause

We use Centos 7 and have found Percona to meet our needs quite well whether we need a single server or a cluster.

Install Percona XtraDB Cluster on Centos 7

Have another answer? Share your knowledge.