1、安装libaio,
yum install libaio
2、卸载mariadb
yum remove mariadb-libs-5.5.41-2.el7_0.x86_64
3、下载mysql yumrepository
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
4、添加Mysql yumrepository到系统列表的中,执行
yum localinstall mysql-community-release-el7-5.noarch.rpm
5、查看yum源中的版本
yum repolist all | grep mysql
mysql-connectors-community/x86_64 MySQLConnectors Community 启用: 24
mysql-connectors-community-source MySQLConnectors Community - Sourc 禁用
mysql-tools-community/x86_64 MySQL Tools Community 启用: 38
mysql-tools-community-source MySQL Tools Community - Source 禁用
mysql55-community/x86_64 MySQL 5.5 Community Server 禁用
mysql55-community-source MySQL 5.5 Community Server - Sourc 禁用
mysql56-community/x86_64 MySQL 5.6 Community Server 启用: 289
mysql56-community-source MySQL 5.6 Community Server - Sourc 禁用
mysql57-community-dmr/x86_64 MySQL 5.7 Community Server Develop 禁用
mysql57-community-dmr-source MySQL 5.7 Community Server Develop 禁用
6、可以通过修改/etc/yum.repos.d/mysql-community.repo文件来决定启用哪个版本,例如启用下面的版本
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
7、查看启用的哪个版本
yum repolist enabled | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community 24
mysql-tools-community/x86_64 MySQL Tools Community 38
mysql56-community/x86_64 MySQL 5.6 CommunityServer 289
8、安装mysql,执行下面的命令
yum install mysql-community-server
需要安装下图所示的包
依赖关系解决
=================================================================================================================================================
Package 架构 版本 源 大小
=================================================================================================================================================
正在安装:
mysql-community-server x86_64 5.6.34-2.el7 mysql56-community 59 M
为依赖而安装:
mysql-community-client x86_64 5.6.34-2.el7 mysql56-community 19 M
mysql-community-common x86_64 5.6.34-2.el7 mysql56-community 257 k
mysql-community-libs x86_64 5.6.34-2.el7 mysql56-community 2.0 M
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k
9、启动mysql
systemctl start mysqld
10、查看mysql状态
systemctl status mysqld
mysqld.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
Active: active (running) since 六 2016-10-29 03:57:59CST; 56s ago
Process: 4549 ExecStartPost=/usr/bin/mysql-systemd-start post(code=exited, status=0/SUCCESS)
Process: 4489 ExecStartPre=/usr/bin/mysql-systemd-start pre(code=exited, status=0/SUCCESS)
MainPID: 4548 (mysqld_safe)
CGroup: /system.slice/mysqld.service
├─4548 /bin/sh /usr/bin/mysqld_safe
└─4701 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql--plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mys...
10月 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: Support MySQL by buyingsupport/licenses at http://shop.mysql.com
10月 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: Note: new default config filenot created.
10月 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: Please make sure your configfile is current
10月 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: WARNING: Default config file/etc/my.cnf exists on the system
10月 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: This file will be read bydefault by the MySQL server
10月 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: If you do not want to usethis, either remove it, or use the
10月 29 03:57:57localhost.localdomain mysql-systemd-start[4489]: --defaults-file argument tomysqld_safe when starting the server
10月 29 03:57:57localhost.localdomain mysqld_safe[4548]: 161029 03:57:57 mysqld_safe Logging to'/var/log/mysqld.log'.
10月 29 03:57:58 localhost.localdomainmysqld_safe[4548]: 161029 03:57:58 mysqld_safe Starting mysqld daemon withdatabases from /...mysql
10月 29 03:57:59localhost.localdomain systemd[1]: Started MySQL Community Server.
Hint: Some lines were ellipsized, use -l toshow in full.
11、测试安装是否成功
mysql可以正常的登入
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.34 MySQL CommunityServer (GPL)
Copyright (c) 2000, 2016, Oracle and/or itsaffiliates. All rights reserved.
Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
mysql>
12、关闭firewall,禁止firewall开机启动
systemctl stop firewalld.service
systemctl disable firewalld.service
13、安装iptables防火墙,并启用iptables
yum install iptables-services
service iptables start
14、mysql 安全设置
执行mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FORALL MySQL
SERVERS INPRODUCTION USE! PLEASE READ EACH STEPCAREFULLY!
In order to log into MySQL to secure it, we'll need thecurrent
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will beblank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log intothe MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user,allowing anyone
to log into MySQL without having to have a user accountcreated for
them. This isintended 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? [Y/n] y
... Success!
Normally, root should only be allowed to connect from'localhost'. This
ensures that someone cannot guess at the root password fromthe network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MySQL comes with a database named 'test' thatanyone can
access. This is alsointended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping testdatabase...
ERROR 1008 (HY000) at line 1: Can't drop database 'test';database doesn't exist
... Failed! Not critical, keep moving...
- Removingprivileges on test database...
... Success!
Reloading the privilege tables will ensure that all changesmade so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
All done! If you'vecompleted all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
本文转自服务器运维博客51CTO博客,原文链接http://blog.51cto.com/shamereedwine/1868452如需转载请自行联系原作者
neijiade10000