源码方式安装MySQL5.7.11
下载源码:
http://dev.mysql.com/downloads/mysql/
最下面两项
参考安装文档:
http://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html
安装问题:
your C compiler: "CMAKE_C_COMPILER-NOTFOUND" was not found
yum install gcc gcc-c++
---------------
CMake Error at cmake/boost.cmake:81 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>
cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=boost相对目录
--------------
Curses library not found.
rm CMakeCache.txt
yum install ncurses-devel
---------------
cmake后没有错误,只有警告就可以make && make install继续了
比较完整的cmake脚本
cmake . -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/opt/mysql/software/mysql-5.7.11/boost -DCMAKE_INSTALL_PREFIX=/opt/mysql/software -DMYSQL_DATADIR=/opt/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/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
-------------------------
make clean
检查/etc/my.cnf是否存在,存在就先去掉
------------------------
/opt/mysql/software/是安装目录进入到bin
./mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql/software --datadir=/opt/mysql/data
如果datadir有内容则会创建失败,需要删除再执行。
[mysq@mysqlserver bin]$ ./mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql/software --datadir=/opt/mysql/data
2016-04-05T06:54:34.646438Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-04-05T06:54:34.646754Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2016-04-05T06:54:34.647237Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-05T06:54:34.653839Z 0 [Warning] One can only use the --user switch if running as root
2016-04-05T06:54:38.792257Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-04-05T06:54:39.560645Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-04-05T06:54:39.772883Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 44814fae-fafb-11e5-949b-0800272719c9.
2016-04-05T06:54:39.776913Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-04-05T06:54:39.777954Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
------------------------
mysq> bin/mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql/software --datadir=/opt/mysql/data
mysq> bin/mysql_ssl_rsa_setup
mysq> cp support-files/my-default.cnf /etc/my.cnf
mysq> bin/mysqld_safe --user=mysql &
mysq> cp support-files/mysql.server /etc/init.d/mysql
vi /etc/profile
# 在profile文件末尾增加两行
PATH=/opt/mysql/software/bin:/opt/mysql/software/lib:$PATH
export PATH
# 使PATH搜索路径立即生效:
mysq> source /etc/profile
[mysq@mysqlserver software]$ service mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/opt/mysql/data/mysqlserver.pid)
mysq> ps -ef|grep mysql
找到进程kill掉
重启
--------------------
启动出现错误时,查看对应的日志 /opt/mysql/data/mysqlserver.err
Could not create unix socket lock file /my
sql.sock.lock.
2016-04-05T07:22:27.830686Z 0 [ERROR] Unable to setup unix socket lock file.
2016-04-05T07:22:27.830688Z 0 [ERROR] Aborting
修改/etc/my.cnf中, 修改,指定一个有权限的socket
basedir = /opt/mysql/software
datadir = /opt/mysql/data
port = 3306
# server_id = .....
socket = /opt/mysql/data/mysql.sock
-----------------
mysql连接时的错误
在最后一行增加
[mysql]
socket = /opt/mysql/data/mysql.sock
两边的socket保持一致