How to install Mysql in the CentOS
This article will walk through you the process of installing and updating latest MySQL 5.7.9 version onRHEL/CentOS 7/6/5 and Fedora 23/22/21 using MySQL Yum repository via YUM utility.
Step 1: Adding the MySQL Yum Repository
1. We will use official MySQL Yum software repository, which will provides RPM packages for installing the latest version of MySQL server, client, MySQL Utilities, MySQL Workbench, Connector/ODBC, and Connector/Python for the RHEL/CentOS 7/6/5 and Fedora 23-21.
Important: These instructions only works on fresh installation of MySQL on the server, if there is already a MySQL installed using a third-party-distributed RPM package, then I recommend you to upgrade or replace the installed MySQL package using the MySQL Yum Repository”.
Before Upgrading or Replacing old MySQL package, don’t forget to take all important databases backup and configuration files.
2. Now download and add the following MySQL Yum repository to your respective Linux distribution system’s repository list to install the latest version of MySQL (i.e. 5.7.9 released on 21 October 2015).
--------------- On RHEL/CentOS 7 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
--------------- On RHEL/CentOS 6 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
--------------- On RHEL/CentOS 5 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-el5-7.noarch.rpm
--------------- On Fedora 23 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-fc23-7.noarch.rpm
--------------- On Fedora 22 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-fc22-7.noarch.rpm
--------------- On Fedora 21 ---------------
# wget http://dev.mysql.com/get/mysql57-community-release-fc21-7.noarch.rpm
3. After downloading the package for your Linux platform, now install the downloaded package with the following command.
--------------- On RHEL/CentOS 7 ---------------
# yum localinstall mysql57-community-release-el7-7.noarch.rpm
--------------- On RHEL/CentOS 6 ---------------
# yum localinstall mysql57-community-release-el6-7.noarch.rpm
--------------- On RHEL/CentOS 5 ---------------
# yum localinstall mysql57-community-release-el5-7.noarch.rpm
--------------- On Fedora 23 ---------------
# dnf localinstall mysql57-community-release-fc23-7.noarch.rpm
--------------- On Fedora 22 ---------------
# dnf localinstall mysql57-community-release-fc22-7.noarch.rpm
--------------- On Fedora 21 ---------------
# yum localinstall mysql57-community-release-fc21-7.noarch.rpm
The above installation command adds the MySQL Yum repository to system’s repository list and downloads the GnuPG key to verify the integrity of the packages.
4. You can verify that the MySQL Yum repository has been added successfully by using following command.
# yum repolist enabled | grep "mysql.*-community.*"
# dnf repolist enabled | grep "mysql.*-community.*" [On Fedora 22+ versions]
Verify MySQL Yum Repository
Step 2: Installing Latest MySQL Version
5. Install latest version of MySQL (currently 5.7) using the following command.
# yum install mysql-community-server
# dnf install mysql-community-server [On Fedora 22+ versions]
The above command installs all the needed packages for MySQL server mysql-community-server, mysql-community-client, mysql-community-common and mysql-community-libs.
Step 3: Installing MySQL Release Series
6. You can also install different MySQL version using different sub-repositories of MySQL Community Server. The sub-repository for the recent MySQL series (currently MySQL 5.7) is activated by default, and the sub-repositories for all other versions (for example, the MySQL 5.6 or 5.5 series) are deactivated by default.
To install specific version from specific sub-repository, you can use --enable
or --disable
options usingyum-config-manager or dnf config-manager as shown:
# yum-config-manager --disable mysql57-community
# yum-config-manager --enable mysql56-community
------------------ Fedora 22+ Versions ------------------
# dnf config-manager --disable mysql57-community
# dnf config-manager --enable mysql56-community
Step 4: Starting the MySQL Server
7. After successful installation of MySQL, it’s time to start the MySQL server with the following command:
# service mysqld start
You can verify the status of the MySQL server with the help of following command.
# service mysqld status
This is the sample output of running MySQL under my CentOS 7 box.
Redirecting to /bin/systemctl status mysqld.service
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: active (running) since Thu 2015-10-29 05:15:19 EDT; 4min 5s ago
Process: 5314 ExecStart=/usr/sbin/mysqld --daemonize $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 5298 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 5317 (mysqld)
CGroup: /system.slice/mysqld.service
└─5317 /usr/sbin/mysqld --daemonize Oct 29 05:15:19 localhost.localdomain systemd[1]: Started MySQL Server.
Check Mysql Status
8. Now finally verify the installed MySQL version using following command.
# mysql --version mysql Ver 14.14 Distrib 5.7.9, for Linux (x86_64) using EditLine wrapper
Check MySQL Installed Version
Step 5: Securing the MySQL Installation
9. The command mysql_secure_installation allows you to secure your MySQL installation by performing important settings like setting the root password, removing anonymous users, removing root login, and so on.
# mysql_secure_installation
Now follow the onscreen instructions carefully, for reference see the output of the above command below.
Sample Output
Securing the MySQL server deployment. Enter password for user root: Enter New Root Password VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root. Estimated strength of the password: 50
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y New password: Set New MySQL Password Re-enter new password: Re-enter New MySQL 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!
Step 6: Connecting to MySQL Server
10. Connecting to newly installed MySQL server by providing username and password.
# mysql -u root -p
Sample Output:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.7.9 MySQL Community Server (GPL) Copyright (c) 2000, 2015, 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>
Connect to MySQL Server
Step 7: Updating MySQL with Yum
11. Besides fresh installation, you can also do updates for MySQL products and components with the help of following command.
# yum update mysql-server
# dnf update mysql-server [On Fedora 22+ versions]
Update MySQL Version
When new updates are available for MySQL, it will auto install them, if not you will get a message saying NO packages marked for updates.
That’s it, you’ve successfully installed MySQL 5.7.9 on your system. If you’re having any trouble installing feel free to use our comment section for solutions.
How to install Mysql in the CentOS的更多相关文章
- Install MySQL 5.7 on Fedora 25/24, CentOS/RHEL 7.3/6.8/5.11
MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user ...
- Install MySql on CentOS
Installing & Configuring MySQL Server This Howto will show you how to install MySQL 5.x, start t ...
- How to Install MySQL on CentOS 7
CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载 # wget http://dev.mysql.com/get/mysql-communit ...
- Installing MySQL Server on CentOS
MySQL is an open-source relational database. For those unfamiliar with these terms, a database is wh ...
- linux下安装多个mysql实例(摘自国外:How to create multiple mysql instance in CentOS 6.4 and Red Hat 6.4)
How to create multiple mysql instance in CentOS 6.4 and Red Hat 6.4 from:http://sharadchhetri.com/20 ...
- Mysql 5.7 CentOS 7 安装MHA
Table of Contents 1. MHA简介 1.1. 功能 1.2. MHA切换逻辑 1.3. 工具 2. 环境 2.1. 软件 2.2. 环境 3. Mysql 主从复制 3.1. Mys ...
- Install MySQL on Mac by Homebrew
1. 安装mysql brew update brew install mysql 2. 启动mysql mysql.server start 3. 登录mysql mysql -uroot -p ...
- yum install mysql
rpm -qa|grep -i mysqlmysql-libs-5.1.52-1.1.alios6.1.x86_64mysql-5.1.52-1.1.alios6.1.x86_64mysql-deve ...
- 在OSX狮子(Lion)上安装MYSQL(Install MySQL on Mac OSX)
这篇文章简述了在Mac OSX狮子(Lion)上安装MySQL Community Server最新版本v10.6.7的过程. MySQL是最流行的开源数据库管理系统.首先,从MySQL的下载页面上下 ...
随机推荐
- 在Foreda8上安装libaio-0.3.105-2.i386.rpm
libaio-0.3.105-2.i386.rpm是安装MySql必须的包,可以从这里下载:http://pan.baidu.com/share/link?shareid=2348086735& ...
- Java+FlashWavRecorder实现网页录音并上传
[注意] 最新版本号请看这里:http://uikoo9.com/blog/detail/java-flashwavrecorder [前言] 肯定有需求要网页录音,并且要上传.这奇葩需求. 然后找到 ...
- redis 配置步骤
1.下载 2.启动 3.持久化(快照和AOF) 4.主从配置(集群) 5.读写分离 6.自动切换主从 7.哨兵服务(集群) 8.集群锁 9.Session共享
- ZH奶酪:Ubuntu启动/重启/停止apache服务
Start Apache 2 Server /启动apache服务 # /etc/init.d/apache2 start or $ sudo /etc/init.d/apache2 start Re ...
- 算法笔记_177:历届试题 城市建设(Java)
目录 1 问题描述 2 解决方案 1 问题描述 问题描述 栋栋居住在一个繁华的C市中,然而,这个城市的道路大都年久失修.市长准备重新修一些路以方便市民,于是找到了栋栋,希望栋栋能帮助他. C市中有 ...
- js replace 如何替换字符串中的最后一个匹配项
1.正则表达时,贪婪模式,.*会一直匹配到最后一个 // 验证 let str = "123[空]345[空]789[空]0"; let res = str.replace(/(. ...
- ipa 打包遇到的坑
1.xcode 打包 并上传至 appstore 审核 2.预留邮箱 收取 appstore 的审核结果 3.审核通过以后,通过 iTunes Connect 上传正式文件至 appstore ...
- JavaSE入门学习17:Java面向对象之package(包)
一Java包(package) 为了更好地组织类,Java提供了包机制,用于差别类名的命名空间. 包的作用: A把功能类似或相关的类或接口组织在 ...
- visudo精确用户赋权(sudo)
原文BLOG:http://iminmin.blog.51cto.com/689308/455992 sudo" 是Unix/Linux平台上的一个非常有用的工具,允许为非根用户赋予一些合理 ...
- 解决a标签IE下点击后出现轮廓框
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...