MySQL安装

回复 收藏
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
[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

5 初始化数据库
[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]# mkdir -p /data/mysql(独立一个/data/分区)
[root@xin mysql]# chown -R mysql /data/mysql/
[root@xin mysql]# ./scripts/mysql_install_db  --user=mysql --datadir=/data/mysql/
--user 定义数据库的所属主, --datadir 定义数据库安装到哪里,建议放到大空间的分区上,这个目录需要自行创建。
[root@xuexi mysql]# echo $? (结果为0,说明运行结果正常)
0

6 拷贝配置文件
[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@xuexi support-files]# cp my-large.cnf /etc/my.cnf

7 拷贝启动脚本文件并修改其属性
[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]# 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

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@xuexi support-files]# /etc/init.d/mysqld start
Starting MySQL....                                         [确定]

10 检查mysql是否启动
[root@xuexi support-files]# ps aux |grep mysql
root      1922  0.0  0.1   6684  1264 pts/0    S    17:06   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql/ --pid-file=/data/mysql//xuexi.pid
mysql     2046  2.9  4.3 390536 44656 pts/0    Sl   17:06   0:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql --log-error=/data/mysql//xuexi.err --pid-file=/data/mysql//xuexi.pid --socket=/tmp/mysql.sock --port=3306
root      2072  0.0  0.0   6052   764 pts/0    S+   17:07   0:00 grep mysql
[root@xuexi support-files]# netstat -lnp|grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      2046/mysqld
unix  2      [ ACC ]     STREAM     LISTENING     20155  2046/mysqld         /tmp/mysql.sock

[root@xuexi htdocs]# cat /usr/local/mysql/bin/mysqlbug |grep -i confi  (查看MySQL编译)
# This is set by configure
CONFIGURE_LINE="./configure  '--prefix=/usr/local/mysql' '--localstatedir=/usr/local/mysql/data' '--libexecdir=/usr/local/mysql/bin' '--with-comment=MySQL Community Server (GPL)' '--with-server-suffix=' '--enable-thread-safe-client' '--enable-local-infile' '--enable-assembler' '--with-pic' '--with-fast-mutexes' '--with-client-ldflags=-static' '--with-mysqld-ldflags=-static' '--with-zlib-dir=bundled' '--with-big-tables' '--with-ssl' '--with-readline' '--with-embedded-server' '--with-partition' '--with-innodb' '--without-ndbcluster' '--with-archive-storage-engine' '--with-blackhole-storage-engine' '--with-csv-storage-engine' '--without-example-storage-engine' '--with-federated-storage-engine' '--with-extra-charsets=complex' 'CC=/usr/local/gcc-4.3.2/bin/gcc -static-libgcc' 'CFLAGS=-g -O3 -march=i686' 'CXX=/usr/local/gcc-4.3.2/bin/gcc -static-libgcc' 'CXXFLAGS=-g -O3 -march=i686'"


[root@xuexi htdocs]# cp /usr/local/src/php-5.4.45/php.ini-
php.ini-development(开发的)  php.ini-production(生产的)
[root@xuexi etc]# cp /usr/local/src/php-5.4.45/php.ini-production /usr/local/php/etc/php.ini


2016-04-08 19:11 举报
已邀请:
0

qq495966654

赞同来自:

不错 不错 笔记很详细

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: