1.yum 安安装(最简单的方式)
适合对数据要求不高的场合,例如并发不大,公司内部,企业内部的一些场景。大公司门户等把源码自定义RPM包,搭建yum仓库,然后yum安装
yum install mysql-server
2.常规方式编译安装
./configure \ --prefix=/application/mysql5.1.72 \ --with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock \ --localstatedir=/application/mysql5.1.72/data \ --enable-assembler \ --enable-thread-safe-client \ --with-mysqld-user=mysql \ --with-big-tables \ --without-debug \ --with-pthread \ --enable-assembler \ --with-extra-charsets=complex \ --with-readline \ --with-ssl \ --with-embedded-server \ --enable-local-infile \ --with-plugins=partition,innobase \ --with-mysqld-ldflags=-all-static \ --with-client-ldflags=-all-static make && make install
3.cmake或gmake方式编译安装(推荐运维人员使用此方式)
#安装依赖包 yum install ncurses-devel bison gcc gcc-c++ -y #安装cmake tar xf cmake-2.8.8.tar.gz cd cmake-2.8.8 ./configure gmake gmake install cd ../ groupadd mysql useradd mysql -s /sbin/nologin -M -g mysql tar zxf mysql-5.5.32.tar.gz cd mysql-5.5.32 cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \ -DMYSQL_DATADIR=/application/mysql-5.5.32/data \ -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \ -DENABLED_LOCAL_INFILE=ON \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \ -DWITH_FAST_MUTEXES=1 \ -DWITH_ZLIB=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_READLINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DWITH_DEBUG=0 make && make install ln -s /application/mysql-5.5.32/ /application/mysql cp support-files/my-small.cnf /etc/my.cnf #配置环境变量 echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile tail-l /etc/profile source /etc/profile echo $PATH chown -R mysql.mysql /application/mysql/data/ chmod -R 1777 /tmp/ #初始化数据库(与5.1有路径区别) /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql #配置启动服务 cp support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld chkconfig mysqld on /etc/init.d/mysqld start
4.采用二进制方式免编译安装(不需编译,解压初始化后,即可使用,速度快)
###########初始化成功显示如下信息############## WARNING: The host 'A-host' could not be looked up with resolveip. This probably means that your libc libraries are not 100 % compatible with this binary MySQL version. The MySQL daemon, mysqld, should work normally with the exception that host name resolving will not work. This means that you should use IP addresses instead of hostnames when specifying MySQL privileges ! Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /application/mysql//bin/mysqladmin -u root password 'new-password' /application/mysql//bin/mysqladmin -u root -h A-host password 'new-password' Alternatively you can run: /application/mysql//bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /application/mysql/ ; /application/mysql//bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /application/mysql//mysql-test ; perl mysql-test-run.pl Please report any problems with the /application/mysql//scripts/mysqlbug script! You have new mail in /var/spool/mail/root
停留在世界边缘,与之惜别