关于Centos7中安装MySQL冲突和问题解决小结

今天在CentOS7上安装MySQL其所用到的命令如下所示:

[root@admin installtions]# unzip mysql-libs.zip 
Archive:  mysql-libs.zip
   creating: mysql-libs/
  inflating: mysql-libs/MySQL-client-5.6.24-1.el6.x86_64.rpm  
  inflating: mysql-libs/mysql-connector-java-5.1.27.tar.gz  
  inflating: mysql-libs/MySQL-server-5.6.24-1.el6.x86_64.rpm

解压 mysql-libs.zip 包,可以得到相应的文件,通过修改操作权限使其具有一定的操作权限。

[root@admin mysql-libs]# ll
total 76048
-rw-r--r-- 1 root root 18509960 Mar 26  2015 MySQL-client-5.6.24-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  3575135 Dec  1  2013 mysql-connector-java-5.1.27.tar.gz
-rw-r--r-- 1 root root 55782196 Mar 26  2015 MySQL-server-5.6.24-1.el6.x86_64.rpm
[root@admin mysql-libs]# chmod u+x ./*
[root@admin mysql-libs]# ll
total 76048
-rwxr--r-- 1 root root 18509960 Mar 26  2015 MySQL-client-5.6.24-1.el6.x86_64.rpm
-rwxr--r-- 1 root root  3575135 Dec  1  2013 mysql-connector-java-5.1.27.tar.gz
-rwxr--r-- 1 root root 55782196 Mar 26  2015 MySQL-server-5.6.24-1.el6.x86_64.rpm

在使用rpm -ivh *安装的时候,突然出现如下所示的错误显示信息:


[root@admin mysql-libs]# rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm 
Preparing...                          ################################# [100%]
	file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
	file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.6.24-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64

起初并不知道是安装错误的显示,当调用命令启动MySQL时显示如下信息,这时回过来仔细查看上述的信息,发现上述的信息为安装错误的报错信息。

[root@admin mysql-libs]# service mysql status
Redirecting to /bin/systemctl status mysql.service
Unit mysql.service could not be found.

解决方法:
出现以上安装错误列表的原因是:系统已经安装了其他版本的mysql-libs包和mysql数据库文件导致不兼容。通过yum remove的形式删除系统所带的MySQL数据库。

[root@admin mysql-libs]# yum remove mysql-libs
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be erased
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Running transaction check
---> Package postfix.x86_64 2:2.10.1-6.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================
 Package                           Arch                        Version                                Repository                      Size
===========================================================================================================================================
Removing:
 mariadb-libs                      x86_64                      1:5.5.56-2.el7                         @anaconda                      4.4 M
Removing for dependencies:
 postfix                           x86_64                      2:2.10.1-6.el7                         @anaconda                       12 M

Transaction Summary
===========================================================================================================================================
Remove  1 Package (+1 Dependent package)

Installed size: 17 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
icedtea-web-1.7.1-1.el7.x86_64 has missing requires of java-1.8.0-openjdk
jline-1.0-8.el7.noarch has missing requires of java >= ('0', '1.5', None)
  Erasing    : 2:postfix-2.10.1-6.el7.x86_64                                                                                           1/2 
  Erasing    : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                                                      2/2 
  Verifying  : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                                                      1/2 
  Verifying  : 2:postfix-2.10.1-6.el7.x86_64                                                                                           2/2 

Removed:
  mariadb-libs.x86_64 1:5.5.56-2.el7                                                                                                       

Dependency Removed:
  postfix.x86_64 2:2.10.1-6.el7                                                                                                            

Complete!

这时在使用命令对MySQL进行安装显示如下所示:

[root@admin mysql-libs]# rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-server-5.6.24-1.el6        ################################# [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
2019-07-15 14:52:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-07-15 14:52:53 0 [Note] /usr/sbin/mysqld (mysqld 5.6.24) starting as process 14568 ...
2019-07-15 14:52:53 14568 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-07-15 14:52:53 14568 [Note] InnoDB: The InnoDB memory heap is disabled
2019-07-15 14:52:53 14568 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-07-15 14:52:53 14568 [Note] InnoDB: Memory barrier is not used
2019-07-15 14:52:53 14568 [Note] InnoDB: Compressed tables use zlib 1.2.3
2019-07-15 14:52:53 14568 [Note] InnoDB: Using Linux native AIO
2019-07-15 14:52:53 14568 [Note] InnoDB: Using CPU crc32 instructions
2019-07-15 14:52:53 14568 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2019-07-15 14:52:53 14568 [Note] InnoDB: Completed initialization of buffer pool
2019-07-15 14:52:53 14568 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2019-07-15 14:52:53 14568 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2019-07-15 14:52:53 14568 [Note] InnoDB: Database physically writes the file full: wait...
2019-07-15 14:52:53 14568 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2019-07-15 14:52:53 14568 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2019-07-15 14:52:53 14568 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2019-07-15 14:52:53 14568 [Warning] InnoDB: New log files created, LSN=45781
2019-07-15 14:52:53 14568 [Note] InnoDB: Doublewrite buffer not found: creating new
2019-07-15 14:52:53 14568 [Note] InnoDB: Doublewrite buffer created
2019-07-15 14:52:53 14568 [Note] InnoDB: 128 rollback segment(s) are active.
2019-07-15 14:52:53 14568 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-07-15 14:52:53 14568 [Note] InnoDB: Foreign key constraint system tables created
2019-07-15 14:52:53 14568 [Note] InnoDB: Creating tablespace and datafile system tables.
2019-07-15 14:52:53 14568 [Note] InnoDB: Tablespace and datafile system tables created.
2019-07-15 14:52:53 14568 [Note] InnoDB: Waiting for purge to start
2019-07-15 14:52:53 14568 [Note] InnoDB: 5.6.24 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2019-07-15 14:52:53 14568 [Note] Binlog end
2019-07-15 14:52:53 14568 [Note] InnoDB: FTS optimize thread exiting.
2019-07-15 14:52:53 14568 [Note] InnoDB: Starting shutdown...
2019-07-15 14:52:55 14568 [Note] InnoDB: Shutdown completed; log sequence number 1625977


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

此时,表示MySQL的server端已经完全安装。

猜你喜欢

转载自blog.csdn.net/Victory_Lei/article/details/95966945