首页 > 代码库 > centos 编译安装mysql
centos 编译安装mysql
一.mysql5.5.38下载地址:http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.38.tar.gz
二.原出处:http://1567045.blog.51cto.com/1557045/841064
三.简单回顾:
0.准备磁盘,存放mysql的data文件
安装如果磁盘大于2t,需要安装parted,yum search parted yum install xx
- fdisk –l 先查看分区,确定要分的盘符 比如dev/sda
- 进入parted
- makde label
parted /dev/sda
(parted) mklabel gpt Warning: The existing disk label on /dev/sda will be destroyed and all data onthis diskwill be lost. Do you want to continue?Yes/No? yes
- make part
(parted) mkpartPartition name? []? dp1File system type? [ext2]? ext3Start? 0End? 500GB或者0% 100%
- 查看
(parted) print
- 删除
rm 1 #rm后面使用分区的号码
- 格式化
quit 退出parted使用系统的mkfs.ext3 /dev/hdd1
- 挂载
# mount /dev/hdd2 /dp2 dp2需要新建文件夹 makedir -pv /dp2
- 开机自动挂载的设置,上一个设置,重启电脑后,会取消挂载
vim /etc/fstab最后一行加入类似这种/dev/sdb2 /media/Bak2 ext4 defaults 0 0
1.安装所需依赖:
yum -y install ntp vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel pam-devel libtool libtool-ltdl openssl openssl-devel fontconfig-devel libxml2-devel curl-devel libicu libicu-devel libmcrypt libmcrypt-devel libmhash libmhash-devel
2.安装cmake
#下载Cmake的源码包wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz#编译安装tar zxvf cmake-2.8.7.tar.gzcd cmake-2.8.7./configuremake && make install
3.创建 data文件夹,及创建mysql用户
#创建所需目录mkdir -pv /usr/local/mysql/data#创建mysql用户和mysql组groupadd mysqluseradd -g mysql -s /usr/sbin/nologin mysql
#解压源码包tar zxvf mysql-5.5.22.tar.gzcd mysql-5.5.22#cmake编译cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0#安装make && make install#复制配置文件cp support-files/my-medium.cnf /etc/my.cnf#设置权限chmod +x /usr/local/mysqlchown -R mysql:mysql /usr/local/mysqlchown -R mysql:mysql /usr/local/mysql/data#配置开机自动启动cp support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqldchkconfig --add mysqldchkconfig mysqld on#修改配置文件vim /etc/my.cnf#在[mysqld]中添加:datadir = /usr/local/mysql/datalog-error = /usr/local/mysql/data/error.logpid-file = /usr/local/mysql/data/mysql.piduser = mysqltmpdir = /tmp#保存退出#初始化数据库/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data#手动启动MySQLservice mysqld start#测试MySQL是否启动#查看是否有mysql进程ps -ef | grep mysql#查看是否有mysql端口netstat -tnlp | grep 3306#添加mysql的软链接可以使用用户直接使用ln -sv /usr/local/mysql/bin/mysql mysqlln -sv /usr/local/mysql/bin/mysqladmin mysqladminln -sv /usr/local/mysql/bin/mysqldump mysqldump或者编辑/etc/profile在以PATH开头的上一行添加PATH=$PATH:/usr/local/mysql/bin#重读/etc/profile文件. /etc/profile#测试mysql,mysqladmin,mysqldump命令是否能正常使用#读取MySQL的版本信息mysqladmin version
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。