当前位置:Gxlcms > mysql > CentOS6.2上源代码编译安装MySQL-5.6.10以及MySQL-5.5.34

CentOS6.2上源代码编译安装MySQL-5.6.10以及MySQL-5.5.34

时间:2021-07-01 10:21:17 帮助过:29人阅读

CentOS 6.2上源代码编译安装MySQL-5.6.10以及MySQL-5.5.34

CentOS 6.2上源代码编译安装MySQL-5.6.10以及MySQL-5.5.34

1.Mysql5.6.10安装


一.必要软件:
yum -y install gcc gcc-c++ autoconf automake bison ncurses-devel libtool-ltdl-devel* cmake make
二.编译安装
[root@localhost src]#groupadd mysql
[root@localhost src]# useradd mysql -g mysql
[root@localhost src]# pwd
/usr/local/src
[root@localhost src]#mkdir /data/mysql/data -p
[root@localhost src]# mkdir /usr/local/mysql
[root@localhost src]# ls
mysql-5.6.10.tar.gz
Cm/pwd[root@localhost src]# tar -zvxf mysql-5.6.10.tar.gz
Cmake软件可以编译安装也可以不编译安装目前未发现不编译安装有什么问题
Rpm包cmake在centos中版本是 2.6.4-5.el6至于为什么编译安装cmake我个人认为是由于在rhel5中没有或者版本过低有些mysql的安装还是进行在rhel5之上在cmake的官网上也正是这两种版本2.6.4是始终有下载的
下载cmake11.2.1版本
[root@localhost src]# wget
[root@localhost src]# tar -zvxf cmake-2.8.12.1.tar.gz
[root@localhost src]# cd cmake-2.8.12.1
[root@localhost cmake-2.8.12.1]# ./bootstrap
[root@localhost cmake-2.8.12.1]#make&&make install
[root@localhost cmake-2.8.12.1]# cmake --help |head -n1
cmake version 2.8.12.1
[root@localhost cmake-2.8.12.1]# cd /usr/local/src/mysql-5.6.10/storage
有哪些存储引擎的支持可以看一个目录
[root@localhost storage]# ls
archive csv federated innobase myisammrg perfschema
blackhole example heap myisam ndb
[root@localhost storage]# pwd
/usr/local/src/mysql-5.6.10/storage


[root@localhost storage]# cd /usr/local/src/mysql-5.6.10
[root@localhost mysql-5.6.10]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_DATADIR=/data/mysql/data/ \
-DSYSCONFDIR=/etc \
-DWITH_TCP_PORT=3306 \
-DMYSQL_USER=mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1


参数配置详细解释:
其实5.6版本可以所有的关于引擎的参数不填写因为默认是全部给安装的
而5.5则不同关于-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \ 这三个是必须要自己填写的否则的话只能编译出6个引擎;
# /* -DWITH_READLINE=1 # 快捷键功能
# /* -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysqld.sock # 连接数据库socket路径
# /* -DMYSQL_TCP_PORT=3306 # 端口
# /* -DENABLED_LOCAL_INFILE=1 # 允许从本地导入数据


[root@localhost src]#make && make install
[root@localhost src]#cd /usr/local/mysql/scripts/
[root@localhostsrc]#./mysql_install_db--user=mysql --datadir=/data/mysql/data --basedir=/usr/local/mysql
[root@localhost src]#cd /usr/local/mysql/support-files/
[root@localhost src]#cp mysql.server /etc/init.d/mysqld
[root@localhost src]#chmod 755 /etc/init.d/mysqld


[root@localhost src]#cat >>/etc/profile <export PATH=$PATH:/usr/local/mysql/bin
EOF
[root@localhost src]#source /etc/profile
[root@localhost src]#cd /usr/local/mysql/support-files/
[root@localhost support-files]#cp -f my-default.cnf /etc/my.cnf
[root@localhost support-files]#cat >> /etc/my.cnf <log-bin=mysql-bin
expire_logs_days=10
binlog_format=mixed
table_definition_cache=10000
max_connections=1000
key_buffer_size=256M
tmp_table_size=64M
read_buffer_size=4M
read_rnd_buffer_size=16M
sort_buffer_size=64M
thread_cache_size=80
wait_timeout=7200
thread_concurrency = 8
innodb_buffer_pool_size=1024M
innodb_sort_buffer_size=4M
innodb_thread_concurrency=4
innodb_flush_logs_at_trx_commit = 2
EOF


[root@client100 support-files]#chown mysql.mysql /etc/my.cnf
# 将安装目录属主改为mysql[上面更改,到这里又变成root属主了,,所以可以选择更改为mysql]
[root@client100 support-files]#chkconfig --add mysqld
[root@client100 support-files]#chkconfig mysqld on
[root@localhost support-files]# chkconfig --list |grep mysql --234必须为on
[root@client100 support-files]#service mysqld start


[root@client100 support-files]#echo "drop user 'root'@'::1';drop user ''@'localhost';drop user 'root'@'localhost.localdomain';"|mysql
[root@client100 support-files]#mysqladmin -u root password '123456'


---------------------------------------------------------------------


如果起数据库报错多半不外乎两种可能
第一种是你[root@localhostsrc]#./mysql_install_db--user=mysql --datadir=/data/mysql/data --basedir=/usr/local/mysql路径不对那么重新执行这句
第二种则是你有老的数据库没有关闭或者你多次service mysqld start导致的。解决办法如下
[root@localhost support-files]# service mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.. ERROR! The server quit without updating PID file (/data/mysql/data/localhost.localdomain.pid).
[root@localhost support-files]# ps -ef |grep mysql
root 47388 1 0 17:03 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql/data --pid-file=/data/mysql/data/localhost.localdomain.pid
mysql 47503 47388 0 17:03 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/data/localhost.localdomain.err --pid-file=/data/mysql/data/localhost.localdomain.pid
root 62679 11100 0 22:06 pts/0 00:00:00 grep mysql
[root@localhost support-files]# kill -9 47503
[root@localhost support-files]# service mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.. SUCCESS!

linux

人气教程排行