1.系统版本及mysql下载地址
操作系统:Centos 6.5(Centos 7.4下载对应的mysql版本安装同理)
mysql数据库版本:mysql8.0.11
mysql官方网站:
2.安装新版mysql之前,我们需要将系统自带的mariadb-lib卸载
- [bigdata@eric011 software-package]$ rpm -qa | grep mariadb
- mariadb-libs-5.5.56-2.el7.x86_64
- [bigdata@eric011 software-package]$ sudo rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
- [bigdata@eric011 software-package]$ rpm -qa | grep mysql
- mysql-community-common-8.0.11-1.el6.x86_64.rpm
- [bigdata@eric011 software-package]$ sudo rpm -e mysql-community-common-8.0.11-1.el6.x86_64.rpm
查看系统中是否已安装 MySQL 服务,以下提供两种方式:
rpm -qa | grep mysqlyum list installed | grep mysql
有的话,我们就通过 rpm -e 命令 或者 rpm -e --nodeps 命令来卸载掉
[root@xiaoluo ~]# rpm -e mysql // 普通删除模式[root@xiaoluo ~]# rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
3.到mysql的官网下载最新版mysql的rpm集合包并解压:
mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar 选择对应的系统版本
shell> wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar
-
centOS 7: mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar
- centOS 6:mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar
4..其中最简单的安装mysql-server服务,只需要安装如下4个软件包即可,我们可以使用rpm -ivh命令进行安装
- shell> sudo rpm -ivh mysql-community-common-8.0.11-1.el6.x86_64.rpm
- shell> sudo rpm -ivh mysql-community-libs-8.0.11-1.el6.x86_64.rpm --(依赖于common)
- shell> sudo rpm -ivh mysql-community-client-8.0.11-1.el6.x86_64.rpm --(依赖于libs)
- shell> sudo rpm -ivh mysql-community-server-8.0.11-1.el6.x86_64.rpm --(依赖于client、common)
1)遇到错误
处理方法:
1.shell> sudo yum install perl
2.shell> yum install numactl
5.初始化mysql数据库
shell> sudo mysqld --initialize //该命令会在/var/log/mysqld.log生成随机密码
6.修改mysql数据库目录的所属用户及其所属组,然后启动mysql数据库
shell> sudo chown mysql:mysql /var/lib/mysql -R
shell> systemctl start mysqld.service7.根据第6步中的密码,更改root用户的密码,新版的mysql必须先修改root用户的密码,否则登录后是不能执行任何命令的
shell> mysql_secure_installation //根据提示修改root用户密码
8.安装完成,接下来既可以正常操作mysql
-
- [bigdata@eric011 lib]$ mysql -uroot -pxxxx
- mysql: [Warning] Using a password on the command line interface can be insecure.
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 13
- Server version: 8.0.11 MySQL Community Server - GPL
-
- Copyright (c) 2000, 2018, 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> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | mysql |
- | performance_schema |
- | sys |
- +--------------------+
- 4 rows in set (0.01 sec)
-
- mysql> exit
-