前期准备:
yum install gcc gcc-c++ make cmake ncurses-devel bison perl #依赖包
建用户:
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
建立安装目录:
mkdir /data/mysql3306 -pv
chown -R mysql. /data/mysql3306/
下载&解压:
wget –c http://download.softagency.net/MySQL/Downloads/MySQL-5.5/mysql-5.5.44.tar.gz
tar xf mysql-5.5.44.tar.gz
cd mysql-5.5.44
编译安装:
cmake \
-DCMAKE_INSTALL_PREFIX=/data/app/mysql3306 \
-DMYSQL_DATADIR=/data/mysql3306 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_DEBUG=0 \
-DMYSQL_USER=mysql \
-DMYSQL_UNIX_ADDR=/data/mysql3306/mysql3306.sock
make && make install ;echo $? #echo 输出执行结果,0表示成功
配置:
cp -arp /tmp/mysql-5.5.44/support-files/my-large.cnf /data/mysql3306/my.cnf
chown -R mysql. /data/mysql3306/my.cnf
vim /data/mysql3306/my.cnf
添加以下黄底部分参数
[mysqld]
port = 3306
datadir = /data/mysql3306 #数据目录
basedir = /data/app/mysql3306 #程序目录
socket = /data/mysql3306/mysql3306.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU‘s*2 for thread_concurrency
thread_concurrency = 8
log-bin=mysql-bin #二进制日志,主从复制用
binlog_format=mixed #混合模式复制(mixed-based replication,
server-id = 1 #多服务器时,区分mysql服务器身份的ID
初始化mysql:
cd /data/app/mysql3306/
./scripts/mysql_install_db --basedir=/data/app/mysql3306/ --datadir=/data/mysql3306/ --user=mysql
添加为系统服务:
cp /tmp/mysql-5.5.44/support-files/my-medium.cnf /etc/my.cnf
cp /tmp/mysql-5.5.44/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
chkconfig --list |grep mysql #验证
启动
/etc/init.d/mysqld restart
ERROR! MySQL server PID file could not be found! #再次restart 没有再报错
设置密码为123456
/data/app/mysql3306/bin/mysqladmin -uroot password ‘123456‘
登陆
mysql -uroot -p123456
原文地址:http://xiochen.blog.51cto.com/2468288/1672603