参考视频教程:
**高并发 高性能 高可用 MySQL 实战 **
不同mysql版本的安装方法(mysql 5.1,mysql 5.6),rpm安装mysql,源码编译安装mysql
Total 1.1 MB/s | 10 MB 00:09
2.配置mysql,从模板配置文件中拷贝一个
[root@www.linuxshizhan.com ~]# scp /usr/share/mysql/my-large.cnf /etc/my.cnf
3.初始化mysql
[root@www.linuxshizhan.com ~]# mysql_install_db –user=mysql
[root@www.linuxshizhan.com ~]#service mysqld start
[root@www.linuxshizhan.com ~]# /usr/bin/mysqladmin -u root password ‘123456’
通过rpm安装mysql就整完了,是不是非常的简单?
二:下载最新版本的mysql rpm,通过rpm -ivh 安装,这种方式存在安装不成功的风险(跟linux版本有很大关系),建议直接通过yum安装
由于是centos6.4 我这里下载了,当前的最新版本。
MySQL-server-5.6.13-1.el6.x86_64.rpm
[root@www.linuxshizhan.com ~]# rpm -ivh MySQL-server-5.6.13-1.el6.x86_64.rpm
三:mysql源码编译安装mysql-5.1.71
3.1 mysql下载,源码
http://cdn.mysql.com/Downloads/MySQL-5.1/mysql-5.1.71.tar.gz
3.2 建立mysql用户,不带shell哦
useradd -M -s /sbin/nologin mysql
3.3 mysql源码解压
tar xvf mysql-5.1.71.tar.gz
3.4 mysql源码编译安装
[root@www.linuxshizhan.com ~]# cd mysql-5.1.71
[root@www.linuxshizhan.com ~]# ./configure –prefix=/usr/local/mysql \
–with-mysqld-user=mysql \
–with-unix-socket-path=/tmp/mysql.sock \
–localstatedir=/usr/local/mysql/var \
–with-tcp-port=3306 \
–without-debug –enable-assembler \
–sysconfdir=/etc \
–with-mysqld-user=mysql \
–with-charset=utf8 \
–with-collation=utf8_general_ci \
–with-extra-charsets=gbk,utf8 \
–with-client-ldflags=-all-static \
–with-mysqld-ldflags=-all-static \
–with-pthread \
–enable-thread-safe-client \
–with-big-tables \
–with-plugins=all
./configure –prefix=/usr/local/mysql \
–with-mysqld-user=mysql \
–with-unix-socket-path=/tmp/mysql.sock \
–localstatedir=/usr/local/mysql/var \
–with-tcp-port=3306 \
–without-debug –enable-assembler \
–sysconfdir=/etc \
–with-mysqld-user=mysql \
–with-charset=utf8 \
–with-collation=utf8_general_ci \
–with-extra-charsets=gbk,utf8 \
–with-pthread \
–enable-thread-safe-client \
–with-big-tables \
–with-plugins=all
3.5 安装
make;make install
3.6 配置mysql,从模板配置文件中拷贝一个
[root@www.linuxshizhan.com ~]# scp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
3.7 初始化mysql
[root@www.linuxshizhan.com ~]# /usr/local/mysql/bin/mysql_install_db –user=mysql
[root@www.linuxshizhan.com ~]# scp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
[root@www.linuxshizhan.com ~]# chmod 711 /etc/init.d/mysqld
[root@www.linuxshizhan.com ~]# chown mysql:mysql /etc/init.d/mysqld
[root@www.linuxshizhan.com ~]# chkconfig -add mysqld
[root@www.linuxshizhan.com ~]# chkconfig –level 35 mysqld on
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[root@www.linuxshizhan.com ~]#service mysqld start
[root@www.linuxshizhan.com ~]# /usr/bin/mysqladmin -u root password ‘123456’
好了,mysql5.1.7的源码编译安装就介绍到这里啊
四:mysql源码编译安装mysql5.5.6.13 ,我们知道mysql5.5之后的版本源码编译是通过cmake编译啦。
4.1 mysql5.5.6.13下载:
http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.13.tar.gz
4.2 建立mysql用户,不带shell哦
[root@www.linuxshizhan.com ~]# useradd -M -s /sbin/nologin mysql
4.3 安装cmake
[root@www.linuxshizhan.com ~]# yum -y install cmake
4.4 mysql5.5.6.13源码解压
[root@www.linuxshizhan.com ~]# tar xvf mysql-5.5.6.13.tar.gz
4.5 mysql5.5.6.13编译
[root@www.linuxshizhan.com ~]# cd mysql-5.5.6.13
[root@www.linuxshizhan.com ~]# cmake . -DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_EXTRA_CHARSETS=complex \
-DENABLE_DEBUG_SYNC=OFF \
-DWITH_ZLIB=bundled \
-DINSTALL_LAYOUT=STANDALONE \
-DENABLED_PROFILING=ON \
-DMYSQL_MAINTAINER_MODE=OFF \
-DWITH_DEBUG=OFF
[root@www.linuxshizhan.com ~]# make;make install
4.6 初始化mysql
[root@www.linuxshizhan.com ~]# cat > /etc/ld.so.conf.d/libmysql.conf <<EOF
/usr/local/mysql/lib/
EOF
ldconfig
}
[root@www.linuxshizhan.com ~]# cd /usr/local/mysql/
[root@www.linuxshizhan.com ~]# scripts/mysql_install_db –user=mysql
[root@www.linuxshizhan.com ~]# chown -R mysql:mysql /usr/local/mysql
[root@www.linuxshizhan.com ~]# /usr/local/mysql/bin/mysqld_safe &
[root@www.linuxshizhan.com ~]# scp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@www.linuxshizhan.com ~]# chmod 711 /etc/init.d/mysqld
[root@www.linuxshizhan.com ~]# chkconfig –add mysqld
[root@www.linuxshizhan.com ~]# chkconfig –level 35 mysqld on
[root@www.linuxshizhan.com ~]#service mysqld start
[root@www.linuxshizhan.com ~]# /usr/bin/mysqladmin -u root password ‘123456’
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
现在mysql5.6已经内置了memcached,如果要开启memcached话
就在上面的编译参数中加入-DWITH_INNODB_MEMCACHED=1 这一行即可。
如下,其他均一样
cmake . -DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=ON \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=complex \
-DENABLE_DEBUG_SYNC=OFF \
-DWITH_ZLIB=bundled \
-DINSTALL_LAYOUT=STANDALONE \
-DENABLED_PROFILING=ON \
-DMYSQL_MAINTAINER_MODE=OFF \
-DWITH_INNODB_MEMCACHED=1 \
-DENABLE_GPROF=1 \
-DWITH_DEBUG=OFF
make
make install
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
好了。linux下mysql 安装就介绍到这里,各个版本的mysql安装均已经触及,linux系统实战接下来将介绍mysql命令