은 일반적으로 다음과 같은 종류로 나누어진다
yum
rpm 패키지
정기 컴파일 및 설치
cmake 설치
바이너리 패키지 설치 무료
선택 방법
개인용
yum 또는 rpm 패키지 설치个人使用
yum或rpm包安装
企业使用
多用常规编译和cmake及二进制包免安装
数量少的话
5.1.x版本选择使用常规编译安装
5.5.x版本选择使用cmake方式编译安装
数量多的话
直接使用二进制包免安装
首先查看系统环境
[root@localhost ~]# cat /etc/redhat-release CentOS release 6.5 (Final) [root@localhost ~]# uname -r 2.6.32-431.el6.x86_64 [root@localhost ~]# uname -m x86_64
在安装cmake软件,需要安装gcc和gcc-c++
yum -y install gcc
yum -y install gcc-c++
编译安装完cmake后,需要安装依赖包
yum install ncurses-devel -y
记住先要安装用户和组
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd mysql -s /sbin/nologin -M -g mysql
依赖包安装完后,cd进入mysql的目录进行cmake操作
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 \ -DWITH_FAST_MUTEXES=1 \ -DWITH_ZLIB=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_READLINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DWITH_DEBUG=0 \ -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \ 貌似因为64位主机编译不过去!!! -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DEXTRA_CHARSETS=all " 执行成功返回下面代码
Build files have been written to: /root/lamp/mysql-5.5.32
make && install 安装完成
[100%] Built target my_safe_process #此处make完成
....
....
....
-- Installing: /application/mysql-5.5.32/support-files/solaris/postinstall-solaris #此处make install 完成
建立link
ln -s /application/mysql-5.5.32/ application/mysql
建立my.cnf
[root@localhost /]# cp /application/mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
配置环境变量
echo 'export PATH=/application/mysql/bin:$PATH' >> /etc/profile
tail -l /etc/profile
source /etc/profile
echo $PATH
给mysql用户和mysql用户组授权
chown -R mysql.mysql /application/mysql/data/
chmod -R 1777 /tmp/
初始化db脚本,假如有两个ok,就证明成功
[root@localhost /]# cd /application/mysql/scripts/
[root@localhost scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
修改hosts文件
vim /etc/hosts
加入www
加入mysqld脚本
cp /root/lamp/mysql-5.5.32/support-files/mysql.server /etc/init.d/mysqld
加入mysqld脚本执行权限
chmod +x /etc/init.d/mysqld
执行mysqld运行
[root@localhost scripts]# /etc/init.d/mysqld start
Starting MySQL... [确定]
[root@localhost scripts]# netstat -lntup | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2671/mysqld
进入mysql服务器,如果之前配置了环境变量了,就可以执行mysql命令
mysql
删除空用户
mysql> select user,host from mysql.user; | |
---|---|
user | host |
+------+-----------------------+ | |
root | 127.0.0.1 |
root | ::1 |
localhost | |
root | localhost |
localhost.localdomain | |
root | localhost.localdomain |
6 rows in set (0.00 sec)
mysql> delete from mysql.user where user ='';
Query OK, 2 rows affected (0.09 sec)
mysql> select user,host from mysql.user; | |
---|---|
user | host |
+------+-----------------------+ | |
root | 127.0.0.1 |
root | ::1 |
root | localhost |
root | localhost.localdomain |
4 rows in set (0.00 sec)
mysql>
授权system管理员
mysql> grant all privileges on . to system@'localhost' identified by 'longjq' with grant option;
Query OK, 0 rows affected (0.00 sec)
修改mysql密码
/application/mysql//bin/mysqladmin -u root password '123456'
/application/mysql//bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
加入启动管理
[root@localhost scripts]# chkconfig --list mysqld
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭`
기업용
설치 없이 일반 컴파일 및 cmake 및 바이너리 패키지 사용수량이 적은 경우5.1.x 버전의 경우 일반 컴파일 및 설치 사용을 선택하세요
의 경우 버전 5.5.x에서는 cmake를 사용하여 컴파일 설치를 선택하세요 숫자가 많으면