Install MySQL 5.7 on Fedora 25/24, CentOS/RHEL 7.3/6.8/5.11

1. Change root user

Bash


su -
## OR ##
sudo -i

2. Install MySQL YUM repository

Fedora

Bash


## Fedora 25 ##
dnf install https://dev.mysql.com/get/mysql57-community-release-fc25-9.noarch.rpm

## Fedora 24 ##
dnf install https://dev.mysql.com/get/mysql57-community-release-fc24-9.noarch.rpm

## Fedora 23 ##
dnf install https://dev.mysql.com/get/mysql57-community-release-fc23-9.noarch.rpm

CentOS and Red Hat (RHEL)

Bash


## CentOS 7 and Red Hat (RHEL) 7 ##
yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

## CentOS 6 and Red Hat (RHEL) 6 ##
yum localinstall https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm

## CentOS 5 and Red Hat (RHEL) 5 ##
yum localinstall https://dev.mysql.com/get/mysql57-community-release-el5-7.noarch.rpm

3. Update or Install MySQL 5.7.17

Fedora 25/24/23

Bash


dnf install mysql-community-server

CentOS 7.3/6.8/5.11 and Red Hat (RHEL) 7.3/6.8/5.11

Bash


yum install mysql-community-server

4. Start MySQL server and autostart MySQL on boot

Fedora 25/24/23 and CentOS 7.3 and Red Hat (RHEL) 7.3

Bash


systemctl start mysqld.service ## use restart after update

systemctl enable mysqld.service

CentOS 6.8/5.11 and Red Hat (RHEL) 6.8/5.11

Bash


/etc/init.d/mysql start ## use restart after update
## OR ##
service mysql start ## use restart after update

chkconfig --levels 235 mysqld on

5. Get Your Generated Random root Password

Bash


grep ‘A temporary password is generated for [email protected]‘ /var/log/mysqld.log |tail -1

Example Output:

Bash


2015-11-20T21:11:44.229891Z 1 [Note] A temporary password is generated for [email protected]: -et)QoL4MLid

And root password is: -et)QoL4MLid

6. MySQL Secure Installation

  • Change root password
  • Remove anonymous users
  • Disallow root login remotely
  • Remove test database and access to it
  • Reload privilege tables

Start MySQL Secure Installation with following command

Bash


/usr/bin/mysql_secure_installation

Output:

Bash



Securing the MySQL server deployment.

Enter password for user root:
The ‘validate_password‘ plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y

New password: 

Re-enter new password: 

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.

Normally, root should only be allowed to connect from
‘localhost‘. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named ‘test‘ that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done!

Note: If you don’t want some reason, do a “MySQL Secure Installation” then at least it’s very important to change the root user’s password

Bash


mysqladmin -u root password [your_password_here]

## Example ##
mysqladmin -u root password myownsecrectpass

7. Connect to MySQL database (localhost) with password

Bash


mysql -u root -p

## OR ##
mysql -h localhost -u root -p

8. Create Database, Create MySQL User and Enable Remote Connections to MySQL Database

This example uses following parameters:

  • DB_NAME = webdb
  • USER_NAME = webdb_user
  • REMOTE_IP = 10.0.15.25
  • PASSWORD = password123
  • PERMISSIONS = ALL

SQL


## CREATE DATABASE ##
mysql> CREATE DATABASE webdb;

## CREATE USER ##
mysql> CREATE USER ‘webdb_user‘@‘10.0.15.25‘ IDENTIFIED BY ‘password123‘;

## GRANT PERMISSIONS ##
mysql> GRANT ALL ON webdb.* TO ‘webdb_user‘@‘10.0.15.25‘;

##  FLUSH PRIVILEGES, Tell the server to reload the grant tables  ##
mysql> FLUSH PRIVILEGES;

Enable Remote Connection to MariaDB Server –> Open MySQL Port (3306) on Iptables Firewall (as root user again)

1. Fedora 25/24/23 and CentOS/Red Hat (RHEL) 7.3

1.1 Add New Rule to Firewalld

Bash


firewall-cmd --permanent --zone=public --add-service=mysql

## OR ##

firewall-cmd --permanent --zone=public --add --port=3306/tcp

1.2 Restart firewalld.service

Bash


systemctl restart firewalld.service

2. CentOS/Red Hat (RHEL) 6.8/5.11

2.1 Edit /etc/sysconfig/iptables file:

Bash

nano -w /etc/sysconfig/iptables

2.2 Add following INPUT rule:

Bash

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

2.3 Restart Iptables Firewall:

Bash


service iptables restart
## OR ##
/etc/init.d/iptables restart

3. Test remote connection

Bash


mysql -h 10.0.15.25 -u myusername -p

Categories:

Tagged with:

Share

    Related Posts

    时间: 2024-12-21 20:26:38

    Install MySQL 5.7 on Fedora 25/24, CentOS/RHEL 7.3/6.8/5.11的相关文章

    Fedora 25/24/23 nVidia Drivers Install Guide

    https://www.if-not-true-then-false.com/2015/fedora-nvidia-guide/ search Most Popular Featured Linux Programming Servers SQL Advertise If Not True Then False Most Popular Featured Linux Programming Servers SQL Advertise Fedora 25/24/23 nVidia Drivers

    Install Oracle Java JDK/JRE 7u55 on Fedora 20/19, CentOS/RHEL 6.5/5.10

    What's new in Sun/Oracle Java 7 VM Compressed 64-bit object pointers Garbage-First GC (G1) JSR 292: VM support for non-Java languages (InvokeDynamic) Lang JSR 294: Language and VM support for modular programming JSR 308: Annotations on Java types JSR

    How to Install MySQL on CentOS 7

    How to Install MySQL on CentOS 7 Updated Thursday, August 27th, 2015 by Linode Use promo code DOCS10 for $10 credit on a new account. Try this Guide Contribute on GitHub View Project | View File | Edit File MySQL is a popular database management syst

    Fedora 25 (linux平台)开源的PDF文件编辑工具——PDF mod

    Fedora 25 (linux平台)开源的PDF文件编辑工具--PDF mod PDF文件具有非常好的跨平台属性,无论你在哪个平台用哪个PDF阅读器打开,其格式是永远不变的.但是缺点也很明显,文本文件或者图文混排文件,要想再次编辑就有很大难度了. Document viewer作为fedora 25默认PDF阅读器,用来阅读PDF文件没什么大问题,但是如果要修改一下PDF就显得不够强大了. PDF Mod是一款编辑 PDF 文件很方便的工具.包名:pdfmod PDF Mod 让用户可以移除页

    让Fedora 25像centos7默认那样,在目录里随处右键菜单有个“打开终端”选项

    1.如何让Fedora 25像centos7默认那样,在文件夹里随处右键菜单有个"打开终端",这样每次打开终端之后不必再cd到繁复的路径,万一打错还要查看图形界面的路径.其实只需安装一个工具:nautilus-terminal 打开终端,取得root权限,执行一下命令:dnf install -y nautilus-terminal等待安装完成之后,注销重进入就可以看到了. 需要注意一下,如果你的Fedora并不是25,可能会找不到nautilus-terminal 这个包 这时候你可

    How to Install MySQL 5.6 from Official Yum Reposit

    Tags: MySQL Distribution: CentOS Submitted by: Morgan TockerMySQL Community Manager @ Oracle Introduction In October 2013, the MySQL development team officially launched support for yum repositories. This means that you can now ensure that you have t

    Fedora 25 Alpha版本今天发布啦

    时隔Fedora 24发布后的3个月,Fedora项目团队非常开心的宣布任何感兴趣的用户都能下载和测试即将到来的Fedora 25操作系统的Alpha预发布版本,在Fedora 25 Alpha里程碑版本中的最值得关注的新功能就是迁移到下一代Wayland显示服务器和X11(或者X.Org服务器)上,不过仅面向使用GNOME桌面环境的工作站版本. 谈到GNOME,Fedora 25 Alpha版本搭载了GNOME 3.21.4开发版本,在未来将会升级至GNOME 3.22桌面环境(9月21日发布

    VirtualBOX中的Fedora 25 客户机如何全屏化显示?如何安装增强工具?

    首先保证你已经能打开在vbox中安装的Fedora 25. 显示全屏化的时候,却是一个分辨率比较低的窗口.这时候,我们需要安装虚拟机的增强工具. 打开虚拟机的工具栏-->安装增强功能 进入fedora 25虚拟机会有一个挂载好的文件,/run/media/wu/VBOXADDITIONS_5.1.22_115126(后面的版本号会有所差别,wu是我用户名) 打开终端,切换到root用户,执行以下命令,安装需要的包: dnf install -y gcc kernel  kernel-devel

    Fedora 25文件对比、目录对比工具——Meld——Linux平台的对比工具

    处理文件的时候,经常遇到两个非常相似的文件,需要对比.修改.Meld就是专门做这个工作的一款工具.Meld是一个可视的diff和合并工具.Meld是Linux软件,用户使用它可以比较2至3个文件并进行编辑,也可以比较2至3个文件夹并同时进行文件对比. 在Fedora 25上安装Meld: #dnf install -y meld 安装完成后即可启动使用.打开后可以看到,既可以对比文件,也可以对比目录. 可视化做的很好,意思很明确,即使不懂英文同样很容易理解.可以找几个文件测试一下: 还可以直接在