MySQL数据库有四种安装方法:

  1. 源码包编译安装
  2. RPM包安装
  3. 二进制文件安装
  4. 官方yum源安装

这里我们主要介绍二进制包的安装方法

在MySQL官网下载二进制包并且上传到服务器上

解压二进制包

[root@localhost software]# tar zxvf mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz```

> 创建MySQL软件的运行用户

[root@localhost software]# useradd mysql -s /sbin/nologin -M

[root@localhost software]# id mysql

uid=500(mysql) gid=500(mysql) groups=500(mysql)```

将解压出来的二进制包移到到MySQL的安装路径/usr/local下

[root@linux1 software]# cp -R mysql-5.6.32-linux-glibc2.5-x86_64 /usr/local/

切换到/usr/local路径下穿件mysql的软连接方便以后记录版本号和升级

[root@linux1 software]# cd /usr/local/
[root@linux1 local]# ln -s mysql-5.6.32-linux-glibc2.5-x86_64/ mysql
[root@linux1 local]# ll
total 44
drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
lrwxrwxrwx 1 root root 35 Nov 17 23:22 mysql -> mysql-5.6.32-linux-glibc2.5-x86_64/
drwxr-xr-x 13 root root 4096 Nov 17 23:22 mysql-5.6.32-linux-glibc2.5-x86_64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbin
drwxr-xr-x. 5 root root 4096 Nov 17 22:36 share
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src

初始化安装MySQL数据库

初始化的过程中可能会遇到缺少libaio的报错,如下:



自行yum安装即可

[root@linux1 mysql]# yum install libaio libaio-devel -y

修改data目录权限,初始化安装数据库

[root@localhost mysql]# chown -R mysql:mysql data/
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

修改MySQL的配置文件

[root@linux1 mysql]# vim my.cnf
cp: overwrite `/etc/my.cnf'? y
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin # These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql #MySQL的安装目录
datadir = /usr/local/mysql/data #MySQL的数据目录
port = 3306 #MySQL的端口号,可做多实例安装
server_id = 131
socket = /tmp/mysql.sock #通信socket,多实例安装时指定各自的sock # Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

拷贝MySQL的配置文件copy到默认/etc/my.cnf下

[root@linux1 mysql]# /bin/cp my.cnf /etc/my.cnf #使用/bin/cp命令可以直接覆盖源文件不出现提示,在脚本中可以应用

将MySQL的系统命令复制到bin目录下

[root@linux1 bin]# cp * /usr/bin/

指定配置文件启动MySQL

养成指定配置文件的习惯,因为在多实例安装的时候可能使用不同的配置文件,虽然默认的配置文件存放在/etc/my.cnf下

[root@linux1 bin]# ./mysqld_safe --defaults-file=/etc/my.cnf
161117 23:42:39 mysqld_safe Logging to '/usr/local/mysql/data/linux1.err'.
161117 23:42:39 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
^Z
[1]+ Stopped ./mysqld_safe --defaults-file=/etc/my.cnf

检查是否启动MySQL服务

[root@linux1 bin]# ps -ef | grep mysql
root 1842 1740 0 23:42 pts/1 00:00:00 /bin/sh ./mysqld_safe --defaults-file=/etc/my.cnf
mysql 1986 1842 0 23:42 pts/1 00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/linux1.err --pid-file=/usr/local/mysql/data/linux1.pid --socket=/tmp/mysql.sock --port=3306
root 2013 1740 0 23:45 pts/1 00:00:00 grep mysql
[root@linux1 bin]# netstat -lntup | grep 3306
tcp 0 0 :::3306 :::* LISTEN 1986/mysqld

创建MySQL的数据库管理员的账号和密码

此处同样建议指定socket文件启动,socket文件的路径设置到my.cnf文件下

[root@linux1 ~]# mysqladmin -uroot password -S /tmp/mysql.sock
New password:
Confirm new password:

成功进入MySQL数据库

[root@linux1 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.32 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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 |
| test |
+--------------------+
4 rows in set (0.05 sec) mysql>

Mysql数据库二进制安装的更多相关文章

  1. MySQL RPM二进制安装

    +++++++++++++++++++++++++++++++++++++++++++标题:MySQL RPM二进制安装时间:2019年2月24日内容:MySQL RPM二进制安装重点:MySQL R ...

  2. MySQL/MariaDB二进制安装

    本文说明MySQL/MariaDB二进制安装的过程 mysql和mariadb的安装方式基本一致,唯一初始化方式有点不一样 1.规划: 数据文件存储位置                /data/my ...

  3. [转] Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置

    from:  http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 如果要在Linux上做j2ee开发,首先得 ...

  4. Linux学习之CentOS--CentOS6.4下Mysql数据库的安装与配置【转】

      如果要在Linux上做j2ee开发,首先得搭建好j2ee的开发环境,包括了jdk.tomcat.eclipse的安装(这个在之前的一篇随笔中已经有详细讲解了Linux学习之CentOS(七)--C ...

  5. Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置

    原文:http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 如果要在Linux上做j2ee开发,首先得搭建好j ...

  6. Linux学习之CentOS6下Mysql数据库的安装与配置

    转自:http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html 如果要在Linux上做j2ee开发,首先得搭建好j ...

  7. Linux CentOS6.4下Mysql数据库的安装与配置

    一.mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱 ...

  8. CentOS6.4/6.7下Mysql数据库的安装与配置(转载)

    通过RPM方式 给centos  安装mysql  最好有光盘,呵呵,网络也可以下载rpm安装包,不过文件较大. 1 挂载光盘 mount /dev/cdrom /mnt/cdrom/mount: b ...

  9. CentOS6.5下Mysql数据库的安装与配置

    一.mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱 ...

随机推荐

  1. 什么是javascript的回调函数?

    回调函数(callback) 基本上每本书里都会提一提实际上我们几乎每天都在用回调函数,那么如果问你到底什么是回调函数呢? 1. 回调函数是作为参数传递给另一个函数 2. 函数运行到某种程度时,执行回 ...

  2. App字体大小不随系统改变而改变

    转载请注明出处:http://www.cnblogs.com/cnwutianhao/p/6713724.html 在 "设置" , "显示" , " ...

  3. Broker节点

    在druid集群环境中 broker节点的作用是查询.它知道metadata 通过zookeeper发送到了集群中的哪个节点,从而能够准确的查询到.broker也把各个节点的结果汇聚到一个节点中.On ...

  4. R语言写2048游戏

    2048 是一款益智游戏,只需要用方向键让两两相同的数字碰撞就会诞生一个翻倍的数字,初始数字由 2 或者 4 构成,直到游戏界面全部被填满,游戏结束. 编程时并未查看原作者代码,不喜勿喷. 程序结构如 ...

  5. 111_climbing-stairs

    /*@Copyright:LintCode@Author:   Monster__li@Problem:  http://www.lintcode.com/problem/climbing-stair ...

  6. 【从无到有】HTML的初识——part1

    Ⅰ.HTML的初识 1.HTML:超文本标签语言(网页源代码) 2.html的基本结构: <html> <head> <meta charset="utf-8& ...

  7. 我使用的Chrome插件列表

    AdBlock 用来屏蔽广告的,有一些网站会探测出你在使用AdBlock.如果一定要继续浏览的话,你可能需要暂停一下AdBlock Vimium 非常推荐喜欢vim的用户试试看这款插件,它的主要特色是 ...

  8. java异常总结(转载)

    转至 Java常见异常(Runtime Exception )小结 http://www.apkbus.com/android-58405-1-1.html 本文重在Java中异常机制的一些概念.写本 ...

  9. MD5加密。

    MD5 是把文件用open打开,然后对内容hash后的值,所以和文件名无关,和位置无关,和修改时间无关,只与文件内容有关.

  10. 做一个常规的banner图——负边距的使用、banner图的拼法

    在这之前,首先要了解如何设置块级元素在块级元素水平居中 方法: 设置子容器为定位元素 水平居中 left:50%:margin-left:-width/2: 垂直居中 top:50%:margin-t ...