1.1 Mysql安装

mysql是数据库文件(存储数据);

1.下载(猿课论坛链接或者官网)合适版本(官网5.7,我们学习用5.1);免编译的二进制包。源码包就需要编译器编译成能够支持的二进制文件。注意下载的时候和系统位数(32位/64位)的区分
[[email protected] ~]# cd/usr/local/src/

[[email protected] src] wgethttp://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz

[[email protected] src]# ls

[[email protected] src]# du -shmysql-5.1.73-linux-x86_64-glibc23.tar.gz

2.解压 tar

[[email protected] src]# tar zxvf mysql-5.1.73-linux-x86_64-glibc23.tar.gz

[[email protected] src]# ls

mysql-5.1.73-linux-x86_64-glibc23  mysql-5.1.73-linux-x86_64-glibc23.tar.gz

3、建立mysql用户

创建运行mysql的账户不需要登陆  可不创建家目录

[[email protected] src]# useradd -s /sbin/nologin -M mysql

[[email protected] src]# ls /home 验证

aming jishan  mysql  user1 user2  user4  user9

4.移动并重命名。把解压完的数据移动到/usr/local/mysql

 

[[email protected] src]# mv mysql-5.1.73-linux-x86_64-glibc23   /usr/local/mysql 移动带重命名 之前这个目录不存在/usr/local/mysq

查看mysql文件

[[email protected] src]# ls /usr/local/mysql 验证    /usr/local/mysql等于mysql-5.1.73-linux-x86_64-glibc23

bin     data  include         lib mysql-test  scripts  sql-bench

COPYING docs  INSTALL-BINARY  man README      share    support-files

5.初始化数据库

进入   cd  /usr/local/mysql 

[[email protected] src]# cd /usr/local/mysql

创建存放mysql数据的文件夹并更改权限 

[[email protected] mysql]# mkdir -p /data/mysql

[[email protected] mysql]# chown -R mysql /data/mysql

[[email protected] mysql]#  ./scripts/mysql_install_db --user=mysql  --datadir=/data/mysql 初始化完成就有两个“ok”。也可以用命令 echo$? 检测,如果输出为0 表示成功。

Installing MySQL system tables...

OK

Filling help tables...

OK

备注:如果是版本mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz编译会报错,#因为我的linux是最小化安装的,这里报错缺少共享库文件,没关系,我们安装一下就可以了。 yum install -y libaio

[[email protected] mysql]# ./scripts/mysql_install_db--user=mysql  --datadir=/dat                                  a/mysql

Installing MySQL system tables..../bin/mysqld: errorwhile loading shared librar                                  ies:libaio.so.1: cannot open shared object file: No such file or directory

[[email protected] mysql]# ./scripts/mysql_install_db--user=mysql  --datadir=/data/mysql

Installing MySQL system tables..../bin/mysqld: errorwhile loading shared libraries: libaio.so.1: cannot open shared object file: Nosuch file or directory

[[email protected] mysql]#  yum install -y libaio   5.5版本安装这个yum install -y libaio*

6.拷贝配置文件放在相应的目录里面。

[[email protected] mysql]# cd support-files/ 将配置文件放在相应的目录里面。配置文件存放目录

[[email protected] support-files]# ls

binary-configure   my-huge.cnf            mysqld_multi.server

config.huge.ini    my-innodb-heavy-4G.cnf  mysql-log-rotate

config.medium.ini  my-large.cnf           mysql.server

config.small.ini   my-medium.cnf          ndb-config-2-node.ini

magic              my-small.cnf

[[email protected] support-files]# cp my-large.cnf /etc/my.cnf  先将my-large.cnf拷贝到etc/my.cnf下并覆盖之前的配置文件

cp:是否覆盖"/etc/my.cnf"? y

备注:如果是版本mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz需要执行cpmy-default.cnf /etc/my.cnf

[[email protected] support-files]# ls

binary-configure magic  my-default.cnf mysqld_multi.server mysql-log-rotate  mysql.server

[[email protected] support-files]# cp my-large.cnf /etc/my.cnf

cp: 无法获取"my-large.cnf"的文件状态(stat): 没有那个文件或目录

-bash: syntax error near unexpected token `(‘

[[email protected] support-files]# cp my-default.cnf/etc/my.cnf

cp:是否覆盖"/etc/my.cnf"? y

[[email protected] support-files]# vim my-large.cnf

[mysqld]

port            = 3306

socket          = /tmp/mysql.sock

skip-locking

key_buffer_size = 256M

max_allowed_packet = 1M

table_open_cache = 256

sort_buffer_size = 1M

read_buffer_size = 1M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 64M

thread_cache_size = 8

query_cache_size= 16M

# Try number of CPU‘s*2 forthread_concurrency

thread_concurrency = 8

# Don‘t listen on a TCP/IP port at all.This can be a security enhancement,

# if all processes that need to connect tomysqld run on the same host.

# All interaction with mysqld must be madevia Unix sockets or named pipes.

# Note that using this option withoutenabling named pipes on Windows

# (via the "enable-named-pipe"option) will render mysqld useless!

#

#skip-networking

# Replication Master Server (default)

# binary logging is required forreplication

#log-bin=mysql-bin主从的时候用到 前面输入#注释

# binary logging format - mixed recommended

#binlog_format=mixed

# required unique id between 1 and 2^32 - 1

# defaults to 1 if master-host is not set

# but will not function as a master ifomitted

#server-id       = 1

7.拷贝启动脚本。加入到系统服务列表中并启动服务。

[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld

[[email protected] mysql]# chmod 755 /etc/init.d/mysqld电子书上的说明,视频上介绍无

 

8、修改启动脚本

[[email protected] support-files]# vim /etc/init.d/mysqld

basedir=/usr/local/mysql

datadir=/data/mysql

9、把启动脚本加入系统服务项,并设定开机启动,启动mysql

[[email protected] support-files]# chkconfig --add mysqld    加入服务列表

[[email protected] support-files]# chkconfig mysqld on

[[email protected] support-files]# /etc/init.d/mysqld startservice mysqld start

Starting MySQL.. SUCCESS!

[[email protected] support-files]# netstat -lnp |grep mysql 验证成功

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

unix 2      [ ACC ]     STREAM    LISTENING     29567  3418/mysqld         /tmp/mysql.sock

[[email protected] support-files]#

5.6安装可以参考这个

http://blog.csdn.net/noob_f/article/details/51399335

5.7实战安装mysql-5.7.12可以参考这个

http://ask.apelearn.com/question/13004

时间: 2024-08-03 18:58:50

1.1 Mysql安装的相关文章

MySql基础学习-mysql安装

Linux环境下的安装 1检查是否已经安装 sudo service mysql start #若未安装,则提示: mysql: unrecognized service 2安装MySql #安装 MySQL 服务端.核心程序 sudo apt-get install mysql-server #安装 MySQL 客户端 sudo apt-get install mysql-client 安装过程中,提示确实yes即可,并且会提示设置root密码,设置即可. 3检查安装 sudo netstat

基于CentOS 7 的MySQL安装

基于CentOS 7 的MySQL安装 因为一些原因CentOS 7 用MariaDB代替了mysql数据库,所以首先要从网上下载最新的的MySQL包. 然后安装: [[email protected] /]# yum install -y /media/mysql/mysql-community-* 注:红色为MySQL包所在路径. 然后重新启动MySQL服务: [[email protected] /]# systemctl restart msqld.service 重启完后就可以使用了.

单实例MySQL安装

1.建立账号 [[email protected] ~]# groupadd mysql [[email protected] ~]# useradd -s /sbin/nologin -g mysql -Mmysql useradd参数说明: -s/sbin/nologin 表示禁止该用户登录 -gmysql 指定属于mysql组 -M表示不创建用户家目录 2.配置安装环境 创建目录并授权: [[email protected] ~]# mkdir /home/tools [[email pr

Ubuntu系统下的Mysql安装与使用

摘要 在本篇博文中,笔者将从基础出发,介绍Mysql在Linux环境下的安装和基本使用命令,仅适用于Mysql初学者,大牛请绕道-- 安装Mysql数据库 这里介绍最最简单的安装方式,至于编译安装,可以下载安装包, ./configure 生成Makefile,然后 make clean,  make , make test,  make install  我想这些命令应该很基本了吧,这里不再敖述. 1. 安装命令 [email protected]:~$ sudo apt-get instal

MySQL安装过程中出现“APPLY security settings错误”的解决方式

***********************************************声明****************************************************** 原创作品,出自 "晓风残月xj" 博客,欢迎转载,转载时请务必注明出处(http://blog.csdn.net/xiaofengcanyuexj). 因为各种原因.可能存在诸多不足,欢迎斧正. *******************************************

mysql安装文档(Linux 官网yum安装版)

mysql安装文档(官网yum安装Linx版) 创建时间:2016-12-20 文档目的 在Linux下安装mysql服务端应用. (注:本文档采用yum库安装方式安装mysql应用,本文假设您的系统中没有安装第三方发布的rpm包,如果您已经安装了第三方rpm包,请参考文中"替换第三方发布mysql"的内容) 系统环境 操作系统:centos 7 (3.10.0-229.el7.x86_64) mysql版本:mysql57-community-release-el7-9.noarch

Mysql安装部署

1.安装概览 MySQL有几种不同的产品线,且每种产品线又有很多不同的版本,这里选择当前企业使用最广的社区版MySQL5.5系列作为LNMP的组合环境数据库平台. 企业场景MySQL安装方式一览 序号 MySQL安装方式 特点说明 1 yum/rpm包安装 特点是简单,但是没法定制安装,入门新手常用这种方式. 2 二进制安装 解压软件简单配置后就可以使用,不用安装,速度较快,专业DBA喜欢这种方式,软件名如:mysql-5.5.32-liux2.6-x86_64.tar.gz. 3 源码编译安装

MySQL安装配置

一般,MySql安装完成后,会出现一些状况:秒退.系统服务项.登录不上去等,需要进行一些设置. 首先,将mysql的bin目录加入到path环境变量中. 然后,安装mysqld服务项 进入cmd,mysqld -install mysql --defaults-file="D:\mysql-5.6.17\my.ini",安装成功. 相关命令:启动服务:net start mysql 停止服务:net stop mysql 删除服务:sc delete mysql 若报错,请检查my.i

ubuntu下MySQL安装配置及基本操作

在linux下安装方法: 分为四种:一: 直接用软件仓库自动安装(如:ubuntu下,sudo apt-get install mysql-server; Debain下用yum安装): 二:官网下载deb或rmp安装包,直接双击安装: 三:下载tar安装包,解压到硬盘,然后自己配置mysql: 四:源码编译安装(下载mysql源代码自己编译安装). 前两种不需要自己配置,安装简单:后两种需自行配置文件,需要对mysql较为熟练.主要讲下第三种. 由于MySQL依赖libaio1包,所以先安装l

【转】mysql安装图解

转载地址:http://www.jb51.net/article/23876.htm 很多朋友刚开始接触mysql数据库服务器,下面是网友整理的一篇mysql的安装教程,步骤明细也有详细的说明. MySQL5.0版本的安装图解教程是给新手学习的,当前mysql5.0.96是最新的稳定版本. mysql 下载地址 http://www.jb51.net/softs/2193.html 下面的是MySQL安装的图解,用的可执行文件安装的,详细说明了一下!打开下载的mysql安装文件mysql-5.0