首先下载安装包 MySQL-5.6.41-1.el7.x86_64.rpm-bundle.tar 在oracle中下载

检查linux 中是否存在mysql

使用命令检查:rpm -qa | grep -i mysql

rpm -e --nodeps 找到得包名

找到之后执行删除命令

[root@localhost opt]# rpm -qa |grep mariadb*
mariadb-5.5.35-3.el7.x86_64
mariadb-libs-5.5.35-3.el7.x86_64
mariadb-server-5.5.35-3.el7.x86_64
[root@localhost opt]# rpm -e --nodeps mariadb-5.5.35-3.el7.x86_64

--nodeps强制删除得意思

[root@localhost opt]# find / -name mysql
find: ‘/run/user/1000/gvfs’: 权限不够
/var/lib/pcp/config/pmlogconf/mysql
/var/lib/pcp/pmdas/mysql
/usr/lib64/perl5/vendor_perl/auto/DBD/mysql
/usr/lib64/perl5/vendor_perl/DBD/mysql
/usr/lib64/mysql
/usr/include/mysql
/usr/include/mysql/mysql
[root@localhost opt]# rm -rf /var/lib/pcp/config/pmlogconf/mysql
[root@localhost opt]# rm -rf /var/lib/pcp/pmdas/mysql

全部删除找到得这些

安装

[root@localhost opt]# rpm -ivh MySQL-*.rpm
警告:MySQL-client-5.6.41-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:MySQL-devel-5.6.41-1.el7 ################################# [ 14%]
2:MySQL-client-5.6.41-1.el7 ################################# [ 29%]
3:MySQL-test-5.6.41-1.el7 ################################# [ 43%]
4:MySQL-embedded-5.6.41-1.el7 ################################# [ 57%]
5:MySQL-shared-compat-5.6.41-1.el7 ################################# [ 71%]
6:MySQL-shared-5.6.41-1.el7 ################################# [ 86%]
7:MySQL-server-5.6.41-1.el7 ################################# [100%]
2018-08-28 12:30:56 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-28 12:30:56 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-08-28 12:30:56 0 [Note] /usr/sbin/mysqld (mysqld 5.6.41) starting as process 111710 ...
2018-08-28 12:30:56 111710 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-08-28 12:30:56 111710 [Note] InnoDB: The InnoDB memory heap is disabled
2018-08-28 12:30:56 111710 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-08-28 12:30:56 111710 [Note] InnoDB: Memory barrier is not used
2018-08-28 12:30:56 111710 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-08-28 12:30:56 111710 [Note] InnoDB: Using Linux native AIO
2018-08-28 12:30:56 111710 [Note] InnoDB: Using CPU crc32 instructions
2018-08-28 12:30:56 111710 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-08-28 12:30:56 111710 [Note] InnoDB: Completed initialization of buffer pool
2018-08-28 12:30:56 111710 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-08-28 12:30:56 111710 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-08-28 12:30:56 111710 [Note] InnoDB: Database physically writes the file full: wait...
2018-08-28 12:30:56 111710 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-08-28 12:30:58 111710 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-08-28 12:31:00 111710 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-08-28 12:31:00 111710 [Warning] InnoDB: New log files created, LSN=45781
2018-08-28 12:31:00 111710 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-08-28 12:31:00 111710 [Note] InnoDB: Doublewrite buffer created
2018-08-28 12:31:00 111710 [Note] InnoDB: 128 rollback segment(s) are active.
2018-08-28 12:31:00 111710 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-28 12:31:00 111710 [Note] InnoDB: Foreign key constraint system tables created
2018-08-28 12:31:00 111710 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-08-28 12:31:00 111710 [Note] InnoDB: Tablespace and datafile system tables created.
2018-08-28 12:31:00 111710 [Note] InnoDB: Waiting for purge to start
2018-08-28 12:31:00 111710 [Note] InnoDB: 5.6.41 started; log sequence number 0
A random root password has been set. You will find it in '/home/julong/.mysql_secret'.
2018-08-28 12:31:00 111710 [Note] Binlog end
2018-08-28 12:31:00 111710 [Note] InnoDB: FTS optimize thread exiting.
2018-08-28 12:31:00 111710 [Note] InnoDB: Starting shutdown...
2018-08-28 12:31:02 111710 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2018-08-28 12:31:02 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-28 12:31:02 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-08-28 12:31:02 0 [Note] /usr/sbin/mysqld (mysqld 5.6.41) starting as process 111733 ...
2018-08-28 12:31:02 111733 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-08-28 12:31:02 111733 [Note] InnoDB: The InnoDB memory heap is disabled
2018-08-28 12:31:02 111733 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-08-28 12:31:02 111733 [Note] InnoDB: Memory barrier is not used
2018-08-28 12:31:02 111733 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-08-28 12:31:02 111733 [Note] InnoDB: Using Linux native AIO
2018-08-28 12:31:02 111733 [Note] InnoDB: Using CPU crc32 instructions
2018-08-28 12:31:02 111733 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-08-28 12:31:02 111733 [Note] InnoDB: Completed initialization of buffer pool
2018-08-28 12:31:02 111733 [Note] InnoDB: Highest supported file format is Barracuda.
2018-08-28 12:31:02 111733 [Note] InnoDB: 128 rollback segment(s) are active.
2018-08-28 12:31:02 111733 [Note] InnoDB: Waiting for purge to start
2018-08-28 12:31:02 111733 [Note] InnoDB: 5.6.41 started; log sequence number 1625977
2018-08-28 12:31:02 111733 [Note] Binlog end
2018-08-28 12:31:02 111733 [Note] InnoDB: FTS optimize thread exiting.
2018-08-28 12:31:02 111733 [Note] InnoDB: Starting shutdown...
2018-08-28 12:31:04 111733 [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 '/home/julong/.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@localhost opt]#

安装完成

修改配置文件

cp /usr/share/mysql/my-default.cnf /etc/my.cnf

初始化

[root@localhost bin]# ./mysql_install_db 
Installing MySQL system tables...2018-08-28 12:58:34 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-28 12:58:34 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-08-28 12:58:34 0 [Note] /usr/sbin/mysqld (mysqld 5.6.41) starting as process 113103 ...
2018-08-28 12:58:34 113103 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-08-28 12:58:34 113103 [Note] InnoDB: The InnoDB memory heap is disabled
2018-08-28 12:58:34 113103 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-08-28 12:58:34 113103 [Note] InnoDB: Memory barrier is not used
2018-08-28 12:58:34 113103 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-08-28 12:58:34 113103 [Note] InnoDB: Using Linux native AIO
2018-08-28 12:58:34 113103 [Note] InnoDB: Using CPU crc32 instructions
2018-08-28 12:58:34 113103 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-08-28 12:58:34 113103 [Note] InnoDB: Completed initialization of buffer pool
2018-08-28 12:58:34 113103 [Note] InnoDB: Highest supported file format is Barracuda.
2018-08-28 12:58:34 113103 [Note] InnoDB: 128 rollback segment(s) are active.
2018-08-28 12:58:34 113103 [Note] InnoDB: Waiting for purge to start
2018-08-28 12:58:35 113103 [Note] InnoDB: 5.6.41 started; log sequence number 1625987
2018-08-28 12:58:35 113103 [Note] Binlog end
2018-08-28 12:58:35 113103 [Note] InnoDB: FTS optimize thread exiting.
2018-08-28 12:58:35 113103 [Note] InnoDB: Starting shutdown...
2018-08-28 12:58:36 113103 [Note] InnoDB: Shutdown completed; log sequence number 1625997
OK

Filling help tables...2018-08-28 12:58:36 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-28 12:58:36 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-08-28 12:58:36 0 [Note] /usr/sbin/mysqld (mysqld 5.6.41) starting as process 113126 ...
2018-08-28 12:58:36 113126 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-08-28 12:58:36 113126 [Note] InnoDB: The InnoDB memory heap is disabled
2018-08-28 12:58:36 113126 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-08-28 12:58:36 113126 [Note] InnoDB: Memory barrier is not used
2018-08-28 12:58:36 113126 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-08-28 12:58:36 113126 [Note] InnoDB: Using Linux native AIO
2018-08-28 12:58:36 113126 [Note] InnoDB: Using CPU crc32 instructions
2018-08-28 12:58:36 113126 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-08-28 12:58:36 113126 [Note] InnoDB: Completed initialization of buffer pool
2018-08-28 12:58:36 113126 [Note] InnoDB: Highest supported file format is Barracuda.
2018-08-28 12:58:36 113126 [Note] InnoDB: 128 rollback segment(s) are active.
2018-08-28 12:58:36 113126 [Note] InnoDB: Waiting for purge to start
2018-08-28 12:58:37 113126 [Note] InnoDB: 5.6.41 started; log sequence number 1625997
2018-08-28 12:58:37 113126 [Note] Binlog end
2018-08-28 12:58:37 113126 [Note] InnoDB: FTS optimize thread exiting.
2018-08-28 12:58:37 113126 [Note] InnoDB: Starting shutdown...
2018-08-28 12:58:38 113126 [Note] InnoDB: Shutdown completed; log sequence number 1626007
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:

/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

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

WARNING: Found existing config file /usr/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

[root@localhost bin]#

启动mysql

[root@localhost bin]# service mysql start
Starting MySQL.Logging to '/var/lib/mysql/localhost.localdomain.err'.
... SUCCESS!
[root@localhost bin]#

至此安装完成