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
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