首页 > 代码库 > linux下的mysql

linux下的mysql

1、到下面地址下载通用二进制包

wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.53-linux2.6-x86_64.tar.gz

2、具体的安装文档

http://dev.mysql.com/doc/refman/5.5/en/binary-installation.html

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

3、安装解释

创建mysql用户和组,为系统用户和系统组

groupadd -r -g 306 mysql

useradd -r -g 306 -u 306 mysql

解压下载的tar包到指定目录下,一般为/usr/local/mysql

tar -xf mysql-5.5.53-linux2.6-x86_64.tar.gz -C /usr/local

在/usr/local下创建软连接,链接至mysql-5.5.53-linux2.6-x86_64.tar.gz

ln -sv mysql-5.5.53-linux2.6-x86_64.tar.gz mysql

将mysql目录下的文件属主属组改为mysql

chown -R mysql:mysql /usr/local/mysql/*

为了存放数据创建新的逻辑卷

创建新分区fdisk /dev/sda 分区类型改为linux lvm

创建物理卷 pvcreate /dev/sda5

创建卷组  vgcreate myvg /dev/sda5

创建逻辑卷 lvcreate -n mydata -L 5G myvg

格式化  mke2fs -j /dev/myvg/mydata

执行初始化脚本

/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/mydata/data

将mysql目录属主改为root

chown -R root /usr/local/mysql/*

将support-files目录下的配置文件复制到/etc/my.cnf,修改配置文件,添加datadir=/mydata/data

cp /usr/local/mysql/support-files/my-large.cnf  /etc/my.cnf

将support-files目录下的mysql.server复制到/etc/init.d目录下,设置服务自启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

systemctl enable mysqld

输出man文档,库文件,头文件

vim /etc/man_db.conf 添加man文档目录

vim /etc/ld.so.conf.d/mysql.conf 添加lib目录

ln -sv /usr/local/mysql/include /usr/include

linux下的mysql