预编译安装mysql
源码包小,需要从源代码开始经过编译,后安装(耗时,但可自定义需求来安装)
[root@Aliyun ~]# cat /etc/system-releaseCentOS Linux release 7.3.1611 (Core) [root@Aliyun ~]# uname -r3.10.0-514.26.2.el7.x86_64[root@Aliyun src]# mkdir -p /mydata/data[root@Aliyun src]# yum install ncurses-devel libaio-devel cmake bison ##安装依赖包[root@Aliyun src]# pwd/usr/local/src[root@Aliyun src]# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.32.tar.gz[root@Aliyun src]# tar -zvxf mysql-5.5.32.tar.gz[root@Aliyun src]# cd mysql-5.5.32[root@Aliyun mysql-5.5.32]# cmake . \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/mydata/data \-DSYSCONFDIR=/etc \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_ARCHIVE_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITH_READLINE=1 -DWITH_SSL=system \-DWITH_ZLIB=system \-DWITH_LIBWRAP=0 \-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci[root@Aliyun mysql-5.5.32]# make && make install[root@Aliyun mysql-5.5.32]# chown -R mysql:mysql /usr/local/mysql [root@Aliyun mysql-5.5.32]# chown -R mysql:mysql /mydata/data[root@Aliyun scripts]# pwd/usr/local/mysql/scripts[root@Aliyun scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/mydata/data/[root@Aliyun scripts]# ln -sv /usr/local/mysql/include /usr/include/mysql ##建立动态库连接[root@Aliyun scripts]# ldconfig[root@Aliyun mysql-5.5.32]# cd /usr/local/src/mysql-5.5.32/support-files[root@Aliyun support-files]# cp my-small.cnf /etc/my.cnf [root@Aliyun support-files]# cat /etc/my.cnf......basedir =/usr/local/mysql##安装地址datadir = /mydata/data##数据存放路径.......[root@Aliyun support-files]# cp mysql.server /etc/init.d/mysqld ##启动文件[root@Aliyun support-files]# chmod +x /etc/init.d/mysqld
启动Mysql
[root@Aliyun mysql]# service mysqld start[root@Aliyun mysql]# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile ##将mysql命令导入全局路径[root@Aliyun mysql]# mysql -umysql -S /mydata/data/mysql.sock -p #无密码
二进制安装mysql
二进制包很大,是安装好的mysql并打包压缩好,不需要编译,下载完修改参数等就可直接使用
[root@Aliyun src]# wget http://cdn.mysql.com//archives/mysql-5.6/mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz[root@Aliyun src]# tar -zvxf mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz[root@Aliyun src]# mkdir /usr/local/mysql[root@Aliyun src]# cp -rf /usr/local/src/mysql-5.6.12-linux-glibc2.5-x86_64/* /usr/local/mysql/[root@Aliyun scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/mydata/data/[root@Aliyun scripts]# ln -sv /usr/local/mysql/include /usr/include/mysql[root@Aliyun scripts]# ldconfig[root@Aliyun mysql]# cp my.cnf /etc/my.cnf[root@Aliyun mysql]# vim /etc/my.cnf##修改......[mysqld] asedir = /usr/local/mysqldatadir = /mydata/dataport = 3306server_id = 1.........[root@Aliyun mysql]# cp support-files/mysql.server /etc/init.d/mysqld ##添加执行权限[root@Aliyun mysql]# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile ##将mysql命令导入全局路径 [root@Aliyun mysql]# source /etc/profile[root@Aliyun mysql]# service mysqld start[root@Aliyun mysql]# mysql -umysql -S /mydata/data/mysql.sock-p ##无密码