当前位置:Gxlcms > 数据库问题 > mysql数据库5.6 源码安装

mysql数据库5.6 源码安装

时间:2021-07-01 10:21:17 帮助过:21人阅读

通用二进制包 直接解压配置使用 wget  https://downloads.mariadb.com/archives/mysql-5.5/mysql-5.5.39-linux2.6-x86_64.tar.gz

#yum install libaio

mysql-5.5.39-linux2.6-x86_64.tar.gz

解压缩  tar -xf mysql-5.5.39-linux2.6-x86_64.tar.gz -C /usr/local

做软连接 ln -sv /usr/local/mysql-5.5.39-linux2.6-x86_64 /usr/local/mysql

创建mysql用户MySQL组 修改权限 准备初始化

[root@meihua mysql]# groupadd -r -g 306 mysql
[root@meihua mysql]# useradd  -g 306 -r -u 306 mysql
[root@meihua mysql]# id mysql
uid=306(mysql) gid=306(mysql) 组=306(mysql)
[root@meihua mysql]# cd ..
[root@meihua local]# chown -R mysql.mysql /usr/local/mysql/*

配置逻辑卷的时候 默认是centos6  安装的是LVM2 所以

# yum install lvm2 

进行安装后操作管理lvm管理

[root@meihua army]# pvcreate /dev/sdb5
  Physical volume "/dev/sdb5" successfully created
[root@meihua army]# vgcreate myvg /dev/sdb5
  Volume group "myvg" successfully created
[root@meihua army]# lvcreate -n mydata -L 5G myvg
  Logical volume "mydata" created
[root@meihua army]# lvs
  LV     VG   Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  mydata myvg -wi-a----- 5.00g                                                    
[root@meihua army]# mke2fs -j /dev/myvg/mydata 
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736

正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@meihua army]# vim /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Fri Jun 19 20:11:18 2015
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=dc24aa45-f6b8-4d21-a5ad-fd8358b011e1 /                       ext4    defaults
  1 1
UUID=68e2bcd9-1f79-435c-80c8-a22cddd123a6 /boot                   ext4    defaults
  1 2
UUID=741ee383-fa2a-4027-8923-8f19d0ae5bad /usr/local              ext4    defaults
  1 2
UUID=8559f55e-fea9-4700-90ca-30b4504f5165 swap                    swap    defaults
  0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/myvg/mydata        /mydata                 ext3    defaults        0 0
                                                                                    
                                                                                     
                                         
[root@meihua army]# mkdir /mydata
[root@meihua army]# mount -a
[root@meihua army]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/sda5 on /usr/local type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/mapper/myvg-mydata on /mydata type ext3 (rw)
[root@meihua army]# cd /mydata/
[root@meihua mydata]# ls
lost+found
[root@meihua mydata]# mkdir data
[root@meihua mydata]# ll
总用量 20
drwxr-xr-x. 2 root root  4096 6月  24 21:19 data
drwx------. 2 root root 16384 6月  24 21:14 lost+found
[root@meihua mydata]# chown -R mysql.mysql /mydata/data/
[root@meihua mydata]# ls
data  lost+found
[root@meihua mydata]# ll
总用量 20
drwxr-xr-x. 2 mysql mysql  4096 6月  24 21:19 data
drwx------. 2 root  root  16384 6月  24 21:14 lost+found
[root@meihua mydata]# chmod o-rx data/
[root@meihua mydata]# ll
总用量 20
drwxr-x---. 2 mysql mysql  4096 6月  24 21:19 data
drwx------. 2 root  root  16384 6月  24 21:14 lost+found
[root@meihua mydata]# cd /usr/local/mysql

配置环境变量

[root@meihua profile.d]# vim mysql.sh
export PATH=$PATH:/usr/local/mysql/bin

立即生效环境变量

[root@meihua profile.d]# source /etc/profile.d/mysql.sh 
[root@meihua profile.d]# echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/apache/bin:/home/army/bin:/usr/local/apache/bin:/usr/local/mysql/bin

提供mysql的启动脚本  和配置文件  

[root@meihua mysql]# cd support-files/
[root@meihua support-files]# pwd
/usr/local/mysql/support-files
[root@meihua support-files]# ls
binary-configure   magic                   my-medium.cnf        mysql.server     
config.huge.ini    my-huge.cnf             my-small.cnf         ndb-config-2-node.ini
[root@meihua support-files]# cp mysql.server /etc/init.d/mysqld
[root@meihua support-files]# ll /etc/init.d/mysqld 
-rwxr-xr-x. 1 root root 10880 6月  24 22:51 /etc/init.d/mysqld
[root@meihua support-files]# chkconfig --add mysqld
[root@meihua support-files]# chkconfig --list mysqld
mysqld          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
[root@meihua support-files]# 

添加配置MySQL的配置文件 mysql的配置文件默认给我们提供的多个的配置文件要根据的我们机器配置来决定

注意 mysql的 5.6 以后 就可以不用负责 mysql的 配置文件  执行初始化 脚本会自己生成my.cnf 文件

注意一定修改  配置文件的的  datadir = /mydata/data/      //添加这一条数据存放的路径  非常重要

 这里我的服务器是虚拟机的

1个cup  内存是1G 所有使用的是 my-large.cnf

 cp my-large.cnf /etc/my.cnf

#vim /etc/my.cnf 

[mysqld]

port            = 3306

socket          = /tmp/mysql.sock

skip-external-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 for thread_concurrency

thread_concurrency = 4  //这里根据物理CPU 有多少个乘以2 

datadir = /mydata/data/      //添加这一条数据存放的路径  非常重要

初始化mysql 注意初始化的时候 路径

[root@meihua mysql]# pwd
/usr/local/mysql


[root@meihua mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
Installing MySQL system tables...
./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
这初始化错误的 提示没有找到 libraries: libaio.so.1 所有安装 libaiio 
Installation of system tables failed!  Examine the logs in
/mydata/data/ for more information.

You can try to start the mysqld daemon with:

    shell> ./bin/mysqld --skip-grant &

and use the command line tool ./bin/mysql
to connect to the mysql database and look at the grant tables:

    shell> ./bin/mysql -u root mysql
    mysql> show tables

Try ‘mysqld --help‘ if you have problems with paths.  Using --log
gives you a log in /mydata/data/ that may be helpful.

Please consult the MySQL manual section
‘Problems running mysql_install_db‘, and the manual section that
describes problems on your OS.  Another information source are the
MySQL email archives available at http://lists.mysql.com/.

Please check all of the above before submitting a bug report
at http://bugs.mysql.com/

以上是初始化错的的  要重新初始化才行

意权限mysql安装完成后要把MySQL的所有者权限还给root

[root@meihua mysql]# chown -R root /usr/local/mysql/*
[root@meihua mysql]# ll
总用量 200
drwxr-xr-x.  2 root mysql   4096 6月  20 10:43 bin
-rw-r--r--.  1 root mysql  17987 7月  19 2014 COPYING
drwxr-xr-x.  3 root mysql   4096 6月  20 10:43 data


添加mysql 的man 手册帮助文档

[root@meihua mysql]# vim /etc/man.config 

添加这一条

MANPATH /usr/local/mysql/man

输出库文件

MySQL的库文件所在是

[root@meihua lib]# pwd
/usr/local/mysql/lib

[root@meihua ~]# vim /etc/ld.so.conf.d/mysql.conf

添加一条

/usr/local/mysql/lib

执行重新加载 库文件命令

ldconfig -v

输出头文件

[root@meihua ~]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
"/usr/include/mysql" -> "/usr/local/mysql/include/"
[root@meihua ~]# 

mysql 安装配置完成!


本文出自 “army0627” 博客,转载请与作者联系!

mysql数据库5.6 源码安装

标签:mysql 5.6

人气教程排行