热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

centos7.2安装mysql5.7.21

mysql下载地址:https:www.mysql.comdownloads1.进入mysql官网下载页面2.选择mysql数据库3.选择linux版本的

mysql下载地址:https://www.mysql.com/downloads/

1.进入mysql官网下载页面


2.选择mysql数据库



3.选择linux版本的mysql


4.将下载的mysql-5.7.21-linux-glibc2.12-x86_64.tar上传至服务器,我这里是放在home目录

5.解压文件

     [root@VM_0_6_centos home]# tar -xzvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

6.将解压的目录移动至/usr/local/mysql目录

    [root@VM_0_6_centos home]# mv mysql-5.7.21-linux-glibc2.12-x86_64 /usr/local/mysql

7.创建mysql用户组

      [root@VM_0_6_centos local]# groupadd mysql

8.创建一个用户名为mysql的用户并加入mysql用户组

     [root@VM_0_6_centos local]# useradd -r -g mysql mysql

9.进入mysql目录并新建data目录

    [root@VM_0_6_centos local]# cd mysql
    [root@VM_0_6_centos mysql]# mkdir data

10.修改目录权限

    [root@VM_0_6_centos local]# chown -R mysql mysql/

    [root@VM_0_6_centos local]# chgrp -R mysql mysql/

11.进入mysql的bin目录安装和初始化mysql

    [root@VM_0_6_centos local]# cd /usr/local/mysql/bin

    [root@VM_0_6_centos bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/

    如果报./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

    则执行[root@VM_0_6_centos bin]# yum -y install numactl

    命令执行完成后再次执行

    [root@VM_0_6_centos bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/

    2018-03-22T05:52:45.732314Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2018-03-22T05:52:45.732447Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/--datadir=/usr/local/mysql/data/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
    2018-03-22T05:52:46.709894Z 0 [Warning] InnoDB: New log files created, LSN=45790
    2018-03-22T05:52:46.962543Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
    2018-03-22T05:52:47.059116Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3f532669-2d95-11e8-93ab-5254009d2e6a.
    2018-03-22T05:52:47.068644Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

    2018-03-22T05:52:47.069069Z 1 [Note] A temporary password is generated for root@localhost: k4lqoR)jpwTc

    如果包以下错误

    2018-03-22T05:52:45.732447Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/--datadir=/usr/local/mysql/data/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

    则执行以下命令

   [root@VM_0_6_centos data]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US

   如果包以下错误

    2018-03-22T07:08:58.802194Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.

    2018-03-22T07:08:58.802220Z 0 [ERROR] Aborting

    则删除/usr/local/mysql/data目录下的data文件夹,再新建一个data。或者清空data文件夹



12.配置my.cnf

    进入etc目录编辑my.cnf

    [root@VM_0_6_centos bin]#cd /

    [root@VM_0_6_centos /]cd etc

    [root@VM_0_6_centos etc]vim my.cnf

    将以下配置加入到my.cnf中

    [mysql]
    default-character-set=utf8
    port = 3306
     basedir=/usr/local/mysql
     datadir=/usr/local/mysql/data
     max_cOnnections=500
     character-set-server=utf8
     default-storage-engine=INNODB
     lower_case_table_names=1

     max_allowed_packet=20M

13.启动服务

        [root@VM_0_6_centos etc]# cd /usr/local/mysql/support-files

        [root@VM_0_6_centos support-files]# cp mysql.server /etc/init.d/mysql  

        [root@VM_0_6_centos support-files]# chmod +x /etc/init.d/mysql

        [root@VM_0_6_centos bin]# service mysql start

    如果报以下错误

    Starting MySQL.2018-03-22T07:00:17.265252Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.

    ERROR! The server quit without updating PID file (/var/lib/mysql/VM_0_6_centos.pid).

    则执行以下命令

    [root@VM_0_6_centos bin] mkdir /var/log/mariadb 
      [root@VM_0_6_centos bin] touch /var/log/mariadb/mariadb.log 

      [root@VM_0_6_centos bin] chown -R mysql:mysql /var/log/mariadb/

    再次启动服务

    [root@VM_0_6_centos bin]# service mysql start

    Starting MySQL. SUCCESS! 

    出现以上信息说明mysql服务启动成功

14.将mysql服务添加进开机启动项

    [root@VM_0_6_centos support-files]# chkconfig --add mysql 

15.登录数据并修改密码

    进入/usr/local/mysql/bin目录

    [root@VM_0_6_centos bin]# ./mysql -u root -p

    这里的密码是初始化数据库是产生的密码

    登录数据库后,执行以下操作修改root用户密码

    mysql> set password=password("root")

16.设置远程登录权限

    mysql> grant all privileges on *.* to'root' @'%' identified by 'root';

    




    




推荐阅读
  • CentOS7源码编译安装MySQL5.6
    2019独角兽企业重金招聘Python工程师标准一、先在cmake官网下个最新的cmake源码包cmake官网:https:www.cmake.org如此时最新 ... [详细]
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 本文介绍了一款用于自动化部署 Linux 服务的 Bash 脚本。该脚本不仅涵盖了基本的文件复制和目录创建,还处理了系统服务的配置和启动,确保在多种 Linux 发行版上都能顺利运行。 ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • 如何配置Unturned服务器及其消息设置
    本文详细介绍了Unturned服务器的配置方法和消息设置技巧,帮助用户了解并优化服务器管理。同时,提供了关于云服务资源操作记录、远程登录设置以及文件传输的相关补充信息。 ... [详细]
  • 使用Vultr云服务器和Namesilo域名搭建个人网站
    本文详细介绍了如何通过Vultr云服务器和Namesilo域名搭建一个功能齐全的个人网站,包括购买、配置服务器以及绑定域名的具体步骤。文章还提供了详细的命令行操作指南,帮助读者顺利完成建站过程。 ... [详细]
  • 本文详细介绍了Linux系统中init进程的作用及其启动过程,解释了运行级别的概念,并提供了调整服务启动顺序的具体步骤和实例。通过了解这些内容,用户可以更好地管理系统的启动流程和服务配置。 ... [详细]
  • 本文详细记录了在基于Debian的Deepin 20操作系统上安装MySQL 5.7的具体步骤,包括软件包的选择、依赖项的处理及远程访问权限的配置。 ... [详细]
  • 本文详细介绍如何使用Python进行配置文件的读写操作,涵盖常见的配置文件格式(如INI、JSON、TOML和YAML),并提供具体的代码示例。 ... [详细]
  • 深入理解 SQL 视图、存储过程与事务
    本文详细介绍了SQL中的视图、存储过程和事务的概念及应用。视图为用户提供了一种灵活的数据查询方式,存储过程则封装了复杂的SQL逻辑,而事务确保了数据库操作的完整性和一致性。 ... [详细]
  • 本文深入探讨了 Java 中的 Serializable 接口,解释了其实现机制、用途及注意事项,帮助开发者更好地理解和使用序列化功能。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 本文介绍如何通过创建替代插入触发器,使对视图的插入操作能够正确更新相关的基本表。涉及的表包括:飞机(Aircraft)、员工(Employee)和认证(Certification)。 ... [详细]
  • MySQL 数据库迁移指南:从本地到远程及磁盘间迁移
    本文详细介绍了如何在不同场景下进行 MySQL 数据库的迁移,包括从一个硬盘迁移到另一个硬盘、从一台计算机迁移到另一台计算机,以及解决迁移过程中可能遇到的问题。 ... [详细]
  • 本文探讨了如何在 PHP 的 Eloquent ORM 中实现数据表之间的关联查询,并通过具体示例详细解释了如何将关联数据嵌入到查询结果中。这不仅提高了数据查询的效率,还简化了代码逻辑。 ... [详细]
author-avatar
涂凌萱_TLX_9s7_140
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有