mysql初学者使用那种版本_mysql安装(适用于初学者)

应用系统是centos 6.x  mysql 5.1版本

提前可以把selinux 和iptables 关闭

[root@localhost ~]# chkconfig iptables off

[root@localhost ~]# chkconfig ip6tables off

[root@localhost ~]# /etc/init.d/iptables stop

[root@localhost ~]#/etc/init.d/ip6tables stop

[root@localhost ~]# sed -i "s/LINUX=.*/LINUX=disabled/g" /etc/selinux/config

更改完selinux后要想生效需要重启一下服务器,reboot或者shutdown -r now

yum install make apr* autoconf automake gcc gcc-c++  openssl openssl-devel pcre-devel gd  kernel keyutils  patch  perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch

这些是支持包 为了防止报错 提前yum 一下

1 下载MySQL数据库l到/usr/local/src/

[root@xin tmp]#cd /usr/local/src/

[root@xin src]# wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz

有可能会报错:说明你可能没有安装wget工具,执行yum install -y wget安装wget这个工具,这边还要注意一下自己系统的版本有32位和64位的,根据自己的版本下载对应的mysql。下面我安装的是32位,步骤是一样的。

[root@xin src]# ls

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

下载完毕,过程可能有点慢,可能跟自己的网速有点关系。

[root@xuexi src]# du -sh mysql-5.1.73-linux-i686-glibc23.tar.gz

124M    mysql-5.1.73-linux-i686-glibc23.tar.gz

2 解压

[root@xin src]# tar zxvf mysql-5.1.73-linux-i686-glibc23.tar.gz

[root@xin src]# ls

mysql-5.1.73-linux-i686-glibc23

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

[root@xin src]# du -sh mysql-5.1.73-linux-i686-glibc23

410M    mysql-5.1.73-linux-i686-glibc23

3 把解压完的数据移动到/usr/local/mysql

[root@xin src]# mv mysql-5.1.73-linux-i686-glibc23 /usr/local/mysql

4 建立mysql用户

[root@xin src]# useradd -s /sbin/nologin -M mysql

创建一个运行MySQL用户 -s 不登录 -M 不创建家目录

5 拷贝配置文件

[root@xuexi mysql]# ls

bin      data  include         lib  mysql-test  scripts  sql-bench

COPYING  docs  INSTALL-BINARY  man  README      share    support-files

[root@xuexi mysql]#cd support-files/

[root@xuexi 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

[root@110 support-files]# cat /etc/my.cnf

(系统创建的配置文件,不需要,然后直接覆盖就可以了)

[root@xuexi support-files]# cp my-large.cnf /etc/my.cnf

6 拷贝启动脚本文件并修改其属性

[root@xuexi 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

[root@xuexi support-files]# ls /etc/init.d/

abrt-ccpp         cgred       kdump         nfslock      restorecond  smartd

abrtd             cpuspeed    killall       ntpd         rngd         sshd

abrt-oops         crond       lvm2-lvmetad  ntpdate      rpcbind      sssd

acpid             cups        lvm2-monitor  numad        rpcgssd      sysstat

atd               functions   mdmonitor     oddjobd      rpcidmapd    udev-post

auditd            haldaemon   messagebus    portreserve  rpcsvcgssd   winbind

autofs            halt        netconsole    postfix      rsyslog      ypbind

blk-availability  ip6tables   netfs         psacct       sandbox

certmonger        iptables    network       quota_nld    saslauthd

cgconfig          irqbalance  nfs           rdisc        single

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

[root@xuexi support-files]# mkdir -p /data/mysql

(创建一个独立的/data/分区)

[root@xuexi support-files]# chown -R mysql /data/mysql/

(把所有者改成mysql)

[root@xuexi support-files]# vi /etc/init.d/mysqld

# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

# If you change base dir, you must also change datadir. These may get

# overwritten by settings in the MySQL configuration files.

basedir=/usr/local/mysql

datadir=/data/mysql/

[root@xuexi support-files]#ll /etc/init.d/mysqld  (查看权限)

-rwxr-xr-x. 1 root root 12511 4月   8 17:00 /etc/init.d/mysqld

7初始化数据库

[root@xin src]# cd /usr/local/mysql/

[root@xin mysql]# ls

bin      data  include         lib  mysql-test  scripts  sql-bench

COPYING  docs  INSTALL-BINARY  man  README      share    support-files

[root@xin mysql]# ./scripts/mysql_install_db  --user=mysql --datadir=/data/mysql/

初始化库--user定义数据库的所属主,--datadir定义数据库安装到哪里,建议放到大空间的分区上,这个目录需要自行创建。

[root@xuexi mysql]# echo $? (结果为0,说明运行结果正常)

0

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

[root@xuexi support-files]#chkconfig --add mysqld

[root@xuexi support-files]#chkconfig mysqld on

[root@xuexi support-files]# chkconfig --list |grep mysqld

mysqld          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭

[root@localhost mysql]#/etc/init.d/mysqld start

Starting MySQL. SUCCESS!

10 启动成功我们来检测一下

[root@localhost profile.d]# netstat -lnp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name

tcp        0      0 0.0.0.0:3306                0.0.0.0:*

查看一下端口 3306 ok

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

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

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

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

登陆一下 ok,因为是源码包安装,登陆的话路径太长,以后用的时候很麻烦,这边我们更改一下

11 扩展知识

[root@localhost ~]# vim /etc/profile.d/path.sh

新建一个path的文件,添加下面内容:

#!/bin/bash

export PATH=$PATH:/usr/local/mysql/bin

保存,退出。ok  直接输入mysql  哈哈 成功

[root@localhost ~]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

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

Copyright (c) 2000, 2013, 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 安装完毕  谢谢

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值