centos7安装mysql5.6.25

环境centos7

下载mysql安装包下载地址:http://dev.mysql.com/downloads/mysql/

根据需要下载

MySQL-client-5.6.25-1.el6.x86_64.rpm

MySQL-server-5.6.25-1.el6.x86_64.rpm

安装MySQL-server-5.6.25-1.el6.x86_64.rpm包时报如下错误

 1 [root@localhost software]# rpm -ivh MySQL-server-5.6.25-1.el6.x86_64.rpm 
 2 准备中...                          ################################# [100%]
 3     file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
 4     file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
 5     file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
 6     file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
 7     file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
 8     file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
 9     file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
10     file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
11     file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
12     file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
13     file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
14     file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
15     file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
16     file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
17     file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
18     file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
19     file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
20     file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
21     file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
22     file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
23     file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
24     file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
25     file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
26     file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
27     file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
28     file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
29     file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
30     file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
31     file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
32     file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
33     file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
34     file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
35     file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
36     file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
37     file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
38     file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
39     file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
40     file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
41     file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
42     file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
43     file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
44     file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
45     file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
46     file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
47     file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
48     file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
49     file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
50     file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
51     file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.6.25-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64

发现centos本身自带和mysql同源的mariadb数据库,使用如下命令卸载mariadb数据库

[root@localhost software]# rpm -qa|grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
[root@localhost software]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64

再次分别执行

[root@www software]# rpm -ivh MySQL-server-5.6.25-1.el6.x86_64.rpm 
准备中...                          ################################# [100%]
正在升级/安装...
   1:MySQL-server-5.6.25-1.el6        ################################# [100%]
警告:用户mysql 不存在 - 使用root
警告:群组mysql 不存在 - 使用root
2017-01-02 15:50:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-01-02 15:50:47 0 [Note] /usr/sbin/mysqld (mysqld 5.6.25) starting as process 2211 ...
2017-01-02 15:50:47 2211 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-01-02 15:50:47 2211 [Note] InnoDB: The InnoDB memory heap is disabled
2017-01-02 15:50:47 2211 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-01-02 15:50:47 2211 [Note] InnoDB: Memory barrier is not used
2017-01-02 15:50:47 2211 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-01-02 15:50:47 2211 [Note] InnoDB: Using Linux native AIO
2017-01-02 15:50:47 2211 [Note] InnoDB: Using CPU crc32 instructions
2017-01-02 15:50:47 2211 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-01-02 15:50:47 2211 [Note] InnoDB: Completed initialization of buffer pool
2017-01-02 15:50:47 2211 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-01-02 15:50:47 2211 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-01-02 15:50:47 2211 [Note] InnoDB: Database physically writes the file full: wait...
2017-01-02 15:50:47 2211 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-01-02 15:50:49 2211 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-01-02 15:50:49 2211 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-01-02 15:50:49 2211 [Warning] InnoDB: New log files created, LSN=45781
2017-01-02 15:50:49 2211 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-01-02 15:50:50 2211 [Note] InnoDB: Doublewrite buffer created
2017-01-02 15:50:50 2211 [Note] InnoDB: 128 rollback segment(s) are active.
2017-01-02 15:50:50 2211 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-01-02 15:50:50 2211 [Note] InnoDB: Foreign key constraint system tables created
2017-01-02 15:50:50 2211 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-01-02 15:50:50 2211 [Note] InnoDB: Tablespace and datafile system tables created.
2017-01-02 15:50:50 2211 [Note] InnoDB: Waiting for purge to start
2017-01-02 15:50:50 2211 [Note] InnoDB: 5.6.25 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2017-01-02 15:50:52 2211 [Note] Binlog end
2017-01-02 15:50:52 2211 [Note] InnoDB: FTS optimize thread exiting.
2017-01-02 15:50:52 2211 [Note] InnoDB: Starting shutdown...
2017-01-02 15:50:53 2211 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2017-01-02 15:50:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-01-02 15:50:53 0 [Note] /usr/sbin/mysqld (mysqld 5.6.25) starting as process 2233 ...
2017-01-02 15:50:53 2233 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-01-02 15:50:53 2233 [Note] InnoDB: The InnoDB memory heap is disabled
2017-01-02 15:50:53 2233 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-01-02 15:50:53 2233 [Note] InnoDB: Memory barrier is not used
2017-01-02 15:50:53 2233 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-01-02 15:50:53 2233 [Note] InnoDB: Using Linux native AIO
2017-01-02 15:50:53 2233 [Note] InnoDB: Using CPU crc32 instructions
2017-01-02 15:50:53 2233 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-01-02 15:50:53 2233 [Note] InnoDB: Completed initialization of buffer pool
2017-01-02 15:50:54 2233 [Note] InnoDB: Highest supported file format is Barracuda.
2017-01-02 15:50:54 2233 [Note] InnoDB: 128 rollback segment(s) are active.
2017-01-02 15:50:54 2233 [Note] InnoDB: Waiting for purge to start
2017-01-02 15:50:54 2233 [Note] InnoDB: 5.6.25 started; log sequence number 1625977
2017-01-02 15:50:54 2233 [Note] Binlog end
2017-01-02 15:50:54 2233 [Note] InnoDB: FTS optimize thread exiting.
2017-01-02 15:50:54 2233 [Note] InnoDB: Starting shutdown...
2017-01-02 15:50:55 2233 [Note] InnoDB: Shutdown completed; log sequence number 1625987




A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
[root@www software]# rpm -ivh MySQL-client-5.6.25-1.el6.x86_64.rpm 
准备中...                          ################################# [100%]
正在升级/安装...
   1:MySQL-client-5.6.25-1.el6        ################################# [100%]

安装成功后启动mysql服务

[root@www software]# systemctl start mysql.service

运行/usr/bin/mysql_secure_installation

[root@www software]# /usr/bin/mysql_secure_installation



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the 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 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? [Y/n] 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? [Y/n] 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? [Y/n] 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? [Y/n] Y
 ... Success!




All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...

按照如上图的步骤选择自己需要移除和修改的配置,至此mysql安装成功

mysql的简单配置

[root@localhost software]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.6.25 MySQL Community Server (GPL)

由于默认的root账号是只能本机登录,新增远程连接账号,为了方便,我这里新增的是远程管理员账号

mysql> create user 'admin'@'%' identified by 'admin';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'admin'@'%';
Query OK, 0 rows affected (0.00 sec)

 这里mysql的安装和简单配置都完成

安装过程中可能会遇到如下的问题

[root@www software]# rpm -ivh MySQL-server-5.6.25-1.el6.x86_64.rpm 
错误:依赖检测失败:
    libaio.so.1()(64bit) 被 MySQL-server-5.6.25-1.el6.x86_64 需要
    libaio.so.1(LIBAIO_0.1)(64bit) 被 MySQL-server-5.6.25-1.el6.x86_64 需要
    libaio.so.1(LIBAIO_0.4)(64bit) 被 MySQL-server-5.6.25-1.el6.x86_64 需要

很明显缺少libaio包,下载(下载地址)缺少包,并且安装

[root@www software]# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm
--2017-01-02 15:45:21--  http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm
正在解析主机 mirror.centos.org (mirror.centos.org)... 213.184.126.226, 2605:9000:401:102::2
正在连接 mirror.centos.org (mirror.centos.org)|213.184.126.226|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:21708 (21K) [application/x-rpm]
正在保存至: “libaio-0.3.107-10.el6.x86_64.rpm”

100%[=====================================================================================================================================================>] 21,708      59.8KB/s 用时 0.4s   

2017-01-02 15:45:25 (59.8 KB/s) - 已保存 “libaio-0.3.107-10.el6.x86_64.rpm” [21708/21708])

安装此rpm包即可,如下

[root@www software]# rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm
警告:libaio-0.3.107-10.el6.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID c105b9de: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:libaio-0.3.107-10.el6            ################################# [100%]
原文地址:https://www.cnblogs.com/stimlee/p/6242616.html