(二)lamp环境搭建之编译安装mysql
mysql 编译安装
1,在网站上下载: wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15.tar.gz
2,安装cmake yum安装即可。(“CMake”这个名字是“cross platform make”的缩写,)
3,cmake使用报错:
-- The CXX compiler identification is unknown
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.
Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
解决:报错大致都是缺少依赖包,安装这些就差不多了
yum install -y git gcc gcc-c++ ncurses-devel bison
4,再次执行cmake命令
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
5,make && make install
6,报错 make[2]: *** [sql/CMakeFiles/sql.dir/mysqld.cc.o] Error 1
make[1]: *** [sql/CMakeFiles/sql.dir/all] Error 2
make: *** [all] Error 2
解决:make clean
rm CMakeCache.txt
7,创建mysql用户和用户组,更改mysql 目录的默认用户
groupadd mysql
useradd mysql -g mysql -s /sbin/nologin
chown -R mysql:mysql /usr/local/mysql
8,复制配置文件到/etc 目录下
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
9,添加到环境变量中
echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile
source /etc/profile
10,添加进启动项
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
11,初始化mysql数据库报错:
FATAL ERROR: Could not find ./bin/my_print_defaults
解决:在/bin 目录下看能否找到 这个文件,如果有,就到安装目录以相对路劲执行。
如下:./scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
12,PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password' #更改mysql的root密码
./bin/mysqladmin -u root -h tao-ffy.ffy.com password 'new-pass
13,启动mysqld 报错:
Starting MySQL.The server quit without updating PID file (/usr/local/mysql/data/tao-ffy.ffy.com.pid).
解决: chown -R mysql:mysql /usr/local/mysql #改变mysql目录的默认用户和组。
参考 https://jingyan.baidu.com/article/c1465413ac2fb30bfcfc4c3e.html##1