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

2、解压缩到/usr/local/下面,mysql的主目录命名为mysql

如果是.tar.gz文件直接解压  我下载的是.tar 文件 执行

[root@localhost local]# tar -xvf mysql-5.7.16-linux-glibc2.5-i686.tar

  [root@localhost local]# tar xvf mysql-5.7.16-linux-glibc2.5-i686.tar.gz

解压后的文件夹重命名

[root@localhost local]# mv mysql-5.7.16-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....                                         [确定]

以上操作流程如下图

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

[root@localhost support-files]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2016-10-30 21:17:12
q<.yhitwgg!V
[root@localhost support-files]# cd /usr/local/mysql/bin
[root@localhost bin]# mysql -uroot -p

此处特别说明 如果出现-bash: mysql: command not found 错误

出下这种错误一般是由于安装了一键安装脚本后没有对命令做链接,可以用下面的命令找到mysql命令的绝对路径:

find / -name mysql

假设查找到的路径为/usr/local/mysql/bin/mysql,可以使用下面的命令设置一个链接:

ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

然后就可以使用mysql命令了。

利用初始化密码q<.yhitwgg!V登录mysql   操作如下图:

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

未配置的情况下每次登录需要进入bin目录下操作:

7、 复制配置文件

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

此处特别说明 如果出现 下面这种错误

找一下my-default.cnf 文件的位置

[root@localhost ~]# find / -name my-default.cnf

比如在(/usr/local/mysql/support-files/my-default.cnf)位置

作如下操作:
[root@localhost mysql]# cp support-files/my-default.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. 在用户目录下的.bash_profile文件中增加变量【对单一用户生效(永久的)】
  8. 用VI在用户目录下的.bash_profile文件中增加变量,改变量仅会对当前用户有效,并且是“永久的”。
  9. 要让刚才的修改马上生效,需要在用户目录下执行以下代码
  10. # source .bash_profile
  11. 方法三:
  12. 直接运行export命令定义变量【只对当前shell(BASH)有效(临时的)】
  13. 在shell的命令行下直接使用[export变量名=变量值]定义变量,该变量只在当前的shell(BASH)或其子shell(BASH)下是有效的,shell关闭了,变量也就失效了,再打开新shell时就没有这个变量,需要使用的话还需要重新定义。
  14. 例如: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 '000000';

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

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

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

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

[root@localhost mysql]# service iptables stop

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

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

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

[root@localhost mysql]# setenforce 0

setenforce: SELinux is disable

Linux CentOS6.8下解压安装mysql-5.7.14完整介绍的更多相关文章

  1. win7下解压安装mysql的方法

    在win7下通过解压安装mysql 5.7一直出现启动不成功,网上找了好久终于找到一个解决方法,记录一下: 1.解压下载的压缩包 2.在解压目录下,将my-default.ini改名为my.ini, ...

  2. 详解Linux中CentOS6.8下解压安装mysql-5.7.14

    原文:http://blog.csdn.net/yangle4695/article/details/52185859 mysql下载地址:http://dev.mysql.com/downloads ...

  3. Linux CentOS6.5下编译安装MySQL 5.6

    检查:卸载掉原有MySql 因为mysql数据库在Linux上实在是太流行了,所以目前下载的主流Linux系统版本基本上都集成了mysql数据库在里面,我们可以通过如下命令来查看我们的操作系统上是否已 ...

  4. Linux CentOS6.5下编译安装MySQL 5.6.16【给力详细教程】

    一.编译安装MySQL前的准备工作 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel perl 安装cmake,从http://www.cmake ...

  5. Linux(CentOS6.5)下编译安装MySQL Community Server 5.7.12

      组件 官方网站 直接下载地址 备注 mysql http://dev.mysql.com/downloads/mysql/ http://mirrors.sohu.com/mysql/MySQL- ...

  6. Linux平台下源码安装mysql多实例数据库

    Linux平台下源码安装mysql多实例数据库[root@linux-node1 ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6 ...

  7. debian 8 解压安装mysql(版本5.7.19)

    debian 8 解压安装mysql(版本5.7.19)一.下载 根据目标主机的型号官网下载mysql安装包如: mysql-server_5.7.19-1debian8_amd64.deb-bund ...

  8. win 10 上解压安装 MySQL 8

    win 10 上解压安装 MySQL 8 # 进入到mysql的bin目录底下操作: # 初始化mysql mysqld --initialize --console # 安装mysql服务 mysq ...

  9. LNMP搭建01 -- 编译安装MySQL 5.6.14 和 LNMP相关的区别

    [编译安装MySQL 5.6.14] [http://www.cnblogs.com/xiongpq/p/3384681.html ]  [mysql-5.6.14.tar.gz 下载] http:/ ...

随机推荐

  1. c :set标签的陷阱(未解决)

    三层嵌套的list,第二层解套的时候用Cset标签给设置别名,第一个对象正常使用,第二个对象开始传入内存的地址的值,但是无法获取对象属性

  2. cpp项目的组织

    编译篇 较大型cpp项目的代码组织.编译都是深耦合的. 一般提供一个总体的makefile,进入各个模块,又有自己的makefile,这些makefile又都依赖于一些被include的文件的的定义, ...

  3. JSON.stringify 在OA差旅中转换为字符串传给后端,(使用from表单的形式)

    $('#bookForm').find('#formData').val(transInfo.fromData).end().submit(); 这里的val()中的transInfo.fromDat ...

  4. qsort函数、sort函数【转】

    http://blog.163.com/yuhua_kui/blog/static/9679964420142195442766/ 先说明一下:qsort和sort,只能对连续内存的数据进行排序,像链 ...

  5. fastdfs 安装配置

      介绍文档   1.安装 # wget # tar xf download # cd FastDFS/ # ./make.sh 运行文件 有报错信息 compilation terminated. ...

  6. os and shutil

    # os 模块 os.sep 可以取代操作系统特定的路径分隔符.windows下为 '\\'os.name 字符串指示你正在使用的平台.比如对于Windows,它是'nt',而对于Linux/Unix ...

  7. AutoVue打开ProE工程图中文乱码

    解决办法: 在AutoVue安装目录/Bin/allusers.ini中增加 [Options]ProELang=Chinese_cn

  8. C++中vector的remove用法

      我将从remove的复习开始这个条款,因为remove是STL中最糊涂的算法.误解remove很容易,驱散所有关于remove行为的疑虑——为什么它这么做,它是怎么做的——是很重要的. 这是rem ...

  9. sql server远程备份和恢复

    sql server远程备份和恢复 SQLSERVER服务实例名称:192.168.0.2需要备份的数据库名称: a备份机器名称(Client端):192.168.0.3备份机用户:zf 密码:123 ...

  10. docker底层技术概览

    docker解决了云计算环境难于分发并且管理复杂,而用KVM.Xen等虚拟化又浪费系统资源的问题.Docker最初是基于lxc构建了容器引擎,为了提供跨平台支持,后又专门开发了libcontainer ...