1、安装环境准备
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
# yum install cmake -y
# yum install ncurses-devel -y
# useradd -s /sbin/nologin -M MySQL
2、编译环境准备
# mkdir /usr/local/mysql
# mkdir /software
# cd /software/
# tar -zxvf mysql-5.5.32.tar.gz #上传文件:mysql-5.5.32.tar.gz 到: /software 目录
# cd mysql-5.5.32
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/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
3、初始化MySQL数据库
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ \
--datadir=/usr/local/mysql/data \
--user=mysql #初始化数据库
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
##修改文件:/etc/my.cnf ,因为我的MySQL安装在/usr/local/mysql目录下面 #[mysqld]
# datadir = /usr/local/mysql/data
# socket=/usr/local/mysql/tmp/mysql.sock
# sed -i 's/datadir=\/var\/lib\/mysql/datadir=\/usr\/local\/mysql\/data/g' /etc/my.cnf
# sed -i 's/socket=\/var\/lib\/mysql\/mysql.sock/socket=\/usr\/local\/mysql\/tmp\/mysql.sock/g' /etc/my.cnf
# chown -R mysql.mysql /usr/local/mysql
# /etc/init.d/mysqld start #启动数据库服务
# /usr/local/mysql/bin/mysql
# cp /usr/local/mysql/bin/mysql /usr/local/sbin/ #把mysql客户端程序复制到/usr/local/sbin/目录下面
# /usr/local/mysql/bin/mysqladmin -u root password '123456' #更改root用户密码
# mysql -uroot –p123456
>drop user ""@Lab-Srv-02;
>drop user "root"@"::1";
>drop user ""@"localhost";
网站标题:MySQL5.5.32编译安装
网站链接:
http://cdxtjz.cn/article/ijdcse.html