因为没有权限,编译高版本容易进入安装依赖软件的死胡同,属于选择V5.5、V5.6相对较容易编译。
1、安装编译工具
此处仅讲cmake,其他的软件在configure过程会提示。到http://www.cmake.org/files/选择最新版的cmake链接,然后下载安装:
wget http://www.cmake.org/files cd cmake ./configure --prefix=/home/cmake make && make install
然后将cmake目录加入环境变量(或者在~/local/bin下面建立链接cmake可执行程序的软链接, ~/local/bin是我自己的bin目录, 已经加入到环境变量$PATH中):编辑~/.bashrc或者~/.bash_profile,加入以下内容:
export PATH=/home/cmake:$PATH
让其生效
. ~/.bashrc
2、编译、安装MySQL
(1)到mysql历史版本下载地址https://downloads.mysql.com/archives/community/下载合适的版本。
tar -zxvf mysql.tar.gz cd mysql cmake -DCMAKE_INSTALL_PREFIX=/home/mysql -DMYSQL_TCP_PORT=39393 make && make install
检查端口是否别占用:netstat -apn | grep 39393
(2)将MySQL的bin目录和scripts目录加入环境变量:编辑~/.bashrc或者~/.bash_profile,加入以下内容:
export PATH=~/local/app/mysql/bin:~/local/app/mysql/scripts:$PATH
让其生效
. ~/.bashrc
(3) 配置mysql配置文件my.cnf(本博客的重点)
# Example MySQL config file for very large systems.
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 39393
socket = /home/mysql/mysql.sock
[mysqld]
port = 39393
socket = /home/mysql/mysql.sock
basedir = /home/mysql
datadir = /home/mysql/data
tmpdir= /home/mysql/tmp
innodb_data_home_dir = /home/mysql/data
innodb_data_file_path = ibdata1:1000M:autoextend
#loose-skip-innodb
default-storage-engine = MyISAM
innodb_use_sys_malloc = 0
(4)执行安装命令:./script/mysql_install_db --defaults-file=my.cnf --user=user
(5)启动mysql
180626 12:04:58 mysqld_safe Starting mysqld daemon with databases from home/mysql/data
180626 12:04:58 [Note] home/mysql/bin/mysqld (mysqld 5.5.49) starting as process 51478 ...
180626 12:04:58 [Note] Plugin 'FEDERATED' is disabled.
180626 12:04:58 InnoDB: Mutexes and rw_locks use GCC atomic builtins
180626 12:04:58 InnoDB: Compressed tables use zlib 1.2.3
180626 12:04:58 InnoDB: Using Linux native AIO
180626 12:04:58 InnoDB: Initializing buffer pool, size = 128.0M
180626 12:04:58 InnoDB: Completed initialization of buffer pool
InnoDB: Unable to lock /home/mysql/data/ibdata1, error: 38
180626 12:04:58 InnoDB: Retrying to lock the first data file
InnoDB: Unable to lock home/mysql/data/ibdata1, error: 38
InnoDB: Unable to lock /home/mysql/data/ibdata1, error: 38
InnoDB: Unable to lock /home/mysql/data/ibdata1, error: 38
InnoDB: Unable to lock /home/mysql/data/ibdata1, error: 38
InnoDB: Unable to lock /home/mysql/data/ibdata1, error: 38
InnoDB: Unable to lock
180626 12:06:38 InnoDB: Operating system error number 38 in a file operation.
InnoDB: Error number 38 means 'Function not implemented'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html
180626 12:06:38 InnoDB: Could not open or create data files.
180626 12:06:38 InnoDB: If you tried to add new data files, and it failed here,
180626 12:06:38 InnoDB: you should now edit innodb_data_file_path in my.cnf back
180626 12:06:38 InnoDB: to what it was, and remove the new ibdata files InnoDB created
180626 12:06:38 InnoDB: in this failed attempt. InnoDB only wrote those files full of
180626 12:06:38 InnoDB: zeros, but did not yet use them in any way. But be careful: do not
180626 12:06:38 InnoDB: remove old data files which contain your precious data!
180626 12:06:38 [ERROR] Plugin 'InnoDB' init function returned error.
180626 12:06:38 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
180626 12:06:38 [ERROR] Unknown/unsupported storage engine: InnoDB
180626 12:06:38 [ERROR] Aborting
180626 12:06:38 [Note] /home/mysql/bin/mysqld: Shutdown complete
180626 12:06:38 mysqld_safe mysqld from pid file /home/mysql/data/smp02.local.pid ended
180626 14:33:30 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data
180626 14:33:30 [Note] /home/mysql/bin/mysqld (mysqld 5.5.49) starting as process 39785 ...
180626 14:33:30 [Note] Plugin 'InnoDB' is disabled.
180626 14:33:30 [Note] Plugin 'FEDERATED' is disabled.
180626 14:33:30 [ERROR] Unknown/unsupported storage engine: InnoDB
180626 14:33:30 [ERROR] Aborting
解决方案:在my.cnf中加入
#loose-skip-innodb
default-storage-engine = MyISAM
本文纪念摸索3天让自己濒临崩溃的安装经历。
参考
http://blog.shenwei.me/install-mysql-without-root-privileges/
https://blog.csdn.net/f229338596/article/details/72575403