详解linux中centos6.8下解压安装mysql-5.7.14

yangle4695 yangle4695     2022-11-30     580

关键词:

环境:centos6.8 32位
本教程安装MySQL是通过编译过的二进制文件进行安装。是不针对特定平台的通用安装方法,使用的二进制文件是后缀为.tar.gz的压缩文件
1、下载 http://dev.mysql.com/downloads/mysql/

2、解压缩到/usr/local/下面,mysql的主目录命名为mysql
[root@localhost local]# mkdir soft
[root@localhost local]# cd soft

[root@localhost soft]# tar zvxf mysql-5.7.14-linux-glibc2.5-i686.tar.gz -C /usr/local

[root@localhost soft]# cd ..

[root@localhost local]# mv mysql-5.7.14-linux-glibc2.5-i686/ mysql


3、在mysql下面创建data数据库文件目录

[root@localhost local]# mkdir mysql/data


4、创建mysql的用户组和用户,并对mysql目录设置用户组和用户

[root@localhost local]# groupadd mysql

[root@localhost local]# useradd mysql -g mysql

[root@localhost local]# cd mysql

[root@localhost mysql]# pwd

/usr/local/mysql

[root@localhost mysql]# chown -R mysql .

[root@localhost mysql]# chgrp -R mysql .


5、初始化mysql并启动mysql服务

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

[root@localhost bin]# yum install libaio

已加载插件:fastestmirror, refresh-packagekit, security

设置安装进程

Loading mirror speeds from cached hostfile

* base: mirrors.opencas.cn

* extras: mirrors.btte.net

* updates: mirrors.btte.net

包 libaio-0.3.107-10.el6.i686 已安装并且是最新版本

无须任何处理

[root@localhost bin]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

2016-08-11 12:00:25 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize

2016-08-11 12:00:31 [WARNING] The bootstrap log isn't empty:

2016-08-11 12:00:31 [WARNING] 2016-01-09T04:00:29.262989Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead

2016-08-11T04:00:29.264643Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)

2016-08-11T04:00:29.264653Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)


[root@localhost bin]# cd /usr/local/mysql/support-files

[root@localhost support-files]# ./mysql.server start

Starting MySQL. SUCCESS!


6、登录mysql,此版本最新版不许空密码登录,实际上有个初始化密码保存在/root/.mysql_secret这个文件里面,用这个密码第一次登录后,再修改密码。因此先cat查看下初始化密码(随机的,每次安装看到的密码都不一样):

[root@localhost support-files]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2016-08-11 02:05:38
aeK>:/b,*Z+u



利用初始化密码aeK>:/b,*Z+u开始登录mysql:

[root@localhost ~]# cd /usr/local/mysql/bin

[root@localhost bin]# ./mysql -uroot -p

password:aek>:/b,*Z+u


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 5

Server version: 5.7.10


Copyright (c) 2000, 2015, 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>


显示登录成功,可以执行mysql命令操作了!

未配置的情况下每次登录需要进入bin目录下操作:
[root@localhost ~]# cd /usr/local/mysql/bin

[root@localhost bin]# ./mysql -uroot -p


7、 复制配置文件

[root@localhost mysql] cp support-files/my-medium.cnf /etc/my.cnf

8. 将mysqld服务加入开机自启动项。

*首先需要将scripts/mysql.server服务脚本复制到/etc/init.d/,并重命名为mysqld。

[root@localhostmysql] cp support-files/mysql.server /etc/init.d/mysqld

*通过chkconfig命令将mysqld服务加入到自启动服务项中。

[root@localhost mysql]#chkconfig --add mysqld

*注意服务名称mysqld就是我们将mysql.server复制到/etc/init.d/时重命名的名称。

*查看是否添加成功

[root@localhost mysql]#chkconfig --list mysqld

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

9. 重启系统,mysqld就会自动启动了。

*检查是否启动

[root@localhost mysql]#netstat -anp|grep mysqld

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld

unix 2 [ ACC ] STREAM LISTENING 14396 2365/mysqld /tmp/mysql.sock

*如果不想重新启动,那可以直接手动启动。

[root@localhost mysql]#service mysqld start

Starting MySQL.. SUCCESS!

10 运行客户端程序mysql,在mysql/bin目录中,测试能否连接到mysqld。

[root@localhost mysql]#/usr/local/mysql/bin/mysql -uroot -p

password:
Welcome to the MySQLmonitor. Commands end with ; or \\g.

Your MySQL connection idis 2

Server version:5.5.29-log MySQL Community Server (GPL)



Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.

Oracle is a registeredtrademark of Oracle Corporation and/or its affiliates. Other names may betrademarks of their respective owners.

Type 'help;' or '\\h' forhelp. Type '\\c' to clear the current input statement.

mysql> quit

Bye

*此时会出现mysql>命令提示符,可以输入sql语句,输入quit或exit退出。为了避免每次都输入mysql的全路径/usr/local/mysql/bin/mysql,可将其加入环境变量中,在/etc/profile最后加入两行命令:

  1. 方法一: 
  2. 在/etc/profile文件中最后一行添加变量export PATH=$PATH:/usr/local/mysql/bin
    【对所有用户生效(永久的)】  
  3. 用VI在文件/etc/profile文件中增加变量,该变量将会对Linux下所有用户有效,并且是“永久的”。  
  4. 要让刚才的修改马上生效,需要执行以下代码  
  5. # source /etc/profile  
  6.   
  7. 方法二:  
  8. 在用户目录下的.bash_profile文件中增加变量【对单一用户生效(永久的)】  
  9. 用VI在用户目录下的.bash_profile文件中增加变量,改变量仅会对当前用户有效,并且是“永久的”。  
  10. 要让刚才的修改马上生效,需要在用户目录下执行以下代码  
  11. # source .bash_profile  
  12.   
  13. 方法三:  
  14. 直接运行export命令定义变量【只对当前shell(BASH)有效(临时的)】  
  15. 在shell的命令行下直接使用[export变量名=变量值]定义变量,该变量只在当前的shell(BASH)或其子shell(BASH)下是有效的,shell关闭了,变量也就失效了,再打开新shell时就没有这个变量,需要使用的话还需要重新定义。  
  16. 例如:export PATH=$PATH:/usr/local/mysql/bin
这样就可以在shell中直接输入mysql命令来启动客户端程序了

[root@localhost mysql]#mysql -uroot -p

password:
Welcome to the MySQLmonitor. Commands end with ; or \\g.

Your MySQL connection idis 3

Server version:5.5.29-log MySQL Community Server (GPL)

Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.

Oracle is a registeredtrademark of Oracle Corporation and/or its

affiliates. Other namesmay be trademarks of their respective

owners.

Type 'help;' or '\\h' forhelp. Type '\\c' to clear the current input statement.

mysql>



11、改mysql的root密码,新密码在此为'123456'

mysql> set password=password('123456');

Query OK, 0 rows affected, 1 warning (0.00 sec)


12、设定远程登录mysql。在Linux下为了安全,默认是不允许mysql本机以外的机器访问mysql数据库服务,因此需要重新授权root。方便远程访问。


mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Database changed

mysql> select Host,User from user;

+-----------+-----------+

| Host | User |

+-----------+-----------+

| % | root |

| localhost | mysql.sys |

| localhost | root |

+-----------+-----------+

3 rows in set (0.00 sec)


mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' identified by 'leizm';

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)


授权语句最后的‘leizm’是mysql数据库root用户的新密码。


13、非必要的步骤,如果远程连不上,估计是防火墙的问题,关闭试试:

[root@localhost mysql]# service iptables stop

setenforce 0iptables:将链设置为政策 ACCEPT:filter [确定]

iptables:清除防火墙规则: [确定]

iptables:正在卸载模块: [确定]

[root@localhost mysql]# setenforce 0

setenforce: SELinux is disable

centos6.8下一键安装lamp环境

【下载一键安装软件包】  百度云地址:https://pan.baidu.com/s/1TZqGKtE-46gxW96Ptfp4gA  网址:https://lnmp.org/【步骤】  通过第三方远程工具将软件包传入后,使用tar命令解压,进入解压后的文件夹,执行install.sh,如果是无人值守的请在... 查看详情

centos6.8安装

  VMware下CentOS6.8安装配置简述Linux的安装方法有很多种,下面,我们主要以镜像安装为例,介绍CentOS的安装过程及相关的参数设置,详细步骤如下。 CentOS安装配置打开VMware,单击【创建新虚拟机】按钮。选择【稍后安... 查看详情

centos6.8下安装docker(代码片段)

在CentOS6.8下安装Docker系统版本[[email protected]yum.repos.d]#uname-aLinuxbogon2.6.32-642.el6.x86_64#1SMPTueMay1017:27:01UTC2016x86_64x86_64x86_64GNU/Linux[[email protected]yum.repos.d]#cat/etc/redh 查看详情

linux下tomcat8安装配置详解

linux下tomcat8安装配置详解 Linux下Tomcat8的安装配置安装tomcat前首先要安装对应的jdk并配置Java环境。一、环境准备jdk版本:1.8工具:xShell5xftp5说明:本文是通过Xshell5工具远程连接Linux操作,原理一样.二、安装步骤1、下载安装包... 查看详情

linux安装tomcat详解

(1)使用root用户登录虚拟机,在根目录下的opt文件夹新建一个software文件夹,专门用于存放软件包。            (2)将下载的Tomcattar包传输到Linux系统中的software文件夹中。            ... 查看详情

redis安装详解(代码片段)

1、下载Redis  直接去官网上下载redis-3.0.7.tar:http://download.redis.io/releases/  上面网址中列出了所有的redis版本,这里选择3.0.7进行下载。2、gcc环境  因为Redis是由C开发的,编译时需要依赖gcc环境,所以如果机器没有gcc环境的... 查看详情

centos6.8下docker安装部署

1docker简介    Docker提供了一个可以运行你的应用程序的封套(envelope),或者说容器。它原本是dotCloud启动的一个业余项目,并在前些时候开源了。它吸引了大量的关注和讨论,导致dotCloud把它重命名到DockerInc。它最初... 查看详情

linux下jdk&tomcat安装详解

一、安装tomcat前首先要安装对应的jdk并配置Java环境。1.下载jdk2.在usr目录下建立java安装目录cd/usr//进入usr目录mkdirjava//创建java目录将jdk-8u181-linux-x64.tar.gz上传到java目录下3.解压jdk到当前目录tar-zxvfjdk-8u181-linux-x64.tar.gz得到文件夹jdk1... 查看详情

linux下解压tgz文件--tar命令详解

参数: -c:建立一个压缩文件的参数指令(create的意思); -x:解开一个压缩文件的参数指令! -t:查看tarfile里面的文件! 特别注意,在参数的下达中,c/x/t仅能存在一个!不可同时存在 ! 因为不可能同时... 查看详情

centos6.8下一键安装lamp环境

【下载地址】  https://lamp.sh/  https://lnmp.org/install.html【安装方法】  https://lamp.sh/install.html  执行脚本后,将会依次选择安装的软件包,选择完成后,按任意键运行脚本即可    https://lnmp.org/install.html  安装... 查看详情

linux中centos中httpd源码安装过程详解

在Linux中软件安装有两大类,一类是软件包安装,一类是源代码安装。软件包安装就是指将编译好的二进制封装成rpm包,可以直接使用rpm工具和yum工具安装。源代码安装是指没有编译成二进制,需要通过手动编译的。使用源代码... 查看详情

centos6.8下安装redmine

一、实验环境 centos6.864位所需安装包:ruby-2.3.4.tar.gz、rubygems-1.8.25.tgz、redmine-2.3.2.tar.gz 二、安装步骤1、安装必要的软件包yuminstall-ygccgcc-c++makeapr-develapr-util-develzlib-develcurl-develexpat-develge 查看详情

centos6.8下安装elasticsearch

1.安装java环境2.安装elasticsearchcd/usr/local/srcwgethttps://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.4.tar.gztar-xvfelasticsearch-1.3.4.tar.gzcdelasticsearch-1.3.4./bin/elas 查看详情

centos6.8下安装matlab2009(图片转帖)

前言如何优雅的在centos6.8上安装matlab2009.流程 不过我个人安装过程完后启动matlab的时候又出现了新问题: errorwhileloadingsharedlibraries:libXpm.so.4:cannotopensharedobjectfile:Nosuchfile...系统提示无法找到libXpm.so.4,然后通过命令whereislib... 查看详情

centos7下安装tomcat(详解带图)。

Linux下安装Tomcat。1.首先需要安装他的依赖包jdk并配置Java。我们去浏览器搜索Java,并找到下载页面。然后运用wget进行下载如下图:注:需要把红色箭头标注的地方选中才可以进行复制链接。2.接下来把下载好的安装包解压。我是... 查看详情

centos6.8安装tigervnc实现linux远程桌面

CentOS6.8有默认的安装的vnc位于端口5900:系统->首选项->远程桌面勾选[共享]的选项, 取消勾选[安全]的选项,然后防火墙添加5900端口基本就可以使用了,使用vncviewer直接输入服务Ip地址就可以连接了但是总是出现单击变双击,复... 查看详情

部署阿里云服务器详解1

centos6.8部署java运行环境 xshellwinscp传输----------1.安装jdk下载jdk-linux的rpm文件可以直接rmp命令安装不用手动配置环境变量会自动配置好mkdir/usr/java  传输到java下rpm-ivh rpm文件名2.安装tomcat mkdir/usr/tomcat传输下载好的z... 查看详情

centos6.8下svn安装

1.yum-yinstallsubversionsvnserve--version查看版本2.@创建SVN仓库目录mkdir-p/data/svn/repositories 3.@创建版本库svnadmincreate/data/svn/repositories4.@进入conf目录(该svn版本库配置文件)authz文件是权限控制文件passwd是帐号密码文件svnserve.conf 查看详情