源码安装mysql-5.6.32.tar.gz
http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.32.tar.gz
安装依赖包:
#yum install wget bison gcc gcc-c++ wget make cmake ncurses-devel libtool zilib-devel -y
规划好目录:
# mkdir -p /data/mysqldata/{3306/{data,tmp,binlog,redo-log,undo-log},backup,scritps}
[root@DB]# tree /data/ servers/data/ └── mysqldata ├── 3306 │ ├── binlog │ ├── data │ ├── redo-log │ ├── tmp │ └── undo-log ├── backup └── scritps 9 directories, 0 files
创建mysql用户,授权
#groupadd mysql
#useradd -g mysql mysql
[root@DB /]# chown mysql:mysql -R /data/mysqldata
生成编译配置文件:
[root@DB mysql-5.6.31]# cmake -DCMAKE_INSTALL_PREFIX=/app/servers/mysql-5.6.31 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DCOMPILATION_COMMENT='JSS for mysqltest' -DWITH_READLINE=ON -DSYSCONFDIR=/data/mysqldata/3306 -DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock
上面的cmake是不能成功,初始化不能成功(下面的代码没问题):
cmake -DCMAKE_INSTALL_PREFIX=/app/servers/mysql-5.6.31 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS:STRING=all \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_USER=mysql \ -DMYSQL_TCP_PORT=3306
DCMAKE_INSTALL_PREFIX | mysql安装目录,这里指的是mysql软件的安装路径, |
DDEFAULT_CHARSET | 指定mysql的字符集。 |
DDEFAULT_COLLATION | 指定mysql服务的默认校对规则。 |
DENABLED_LOCAL_INFILE |
是否允许从客户端本地加载数据到Mysql服务端,专用于load data infile语句,默认不允许 |
DWITH_*_STORAGE_ENGINE | 静态编译某种存储引擎。*表示存储引擎名称,1表示开启。 |
DCOMPILATION_COMMENT | 编译信息,后面启动的时候会看到。 |
DWITH_READLINE | mysql输入输出的处理方式 |
DSYSCONFDIR | mysql参数文件的默认路径 |
DMYSQL_UNIX_ADDR | 套接字文件存储路径位置 |
[root@DB mysql-5.6.31]# make && make install
[root@DB mysql-5.6.31]# chown mysql:mysql -R /app/servers/mysql-5.6.31
[root@DB mysql-5.6.31]# chown mysql.mysql /data/mysqldata/3306/my.cnf [root@DB mysql-5.6.31]# ll -h /data/mysqldata/3306/my.cnf -rw-r--r-- 1 mysql mysql 1.6K Aug 17 19:13 /data/mysqldata/3306/my.cnf [root@DB mysql-5.6.31]# cat /data/mysqldata/3306/my.cnf [client] port = 3306 socket = /data/mysqldata/3306/mysql.sock #Mysql Server [mysqld] port = 3306 user = mysql socket = /data/mysqldata/3306/mysql.sock pid-file = /data/mysqldata/3306/mysql.pid basedir = /app/servers/mysql-5.6.31 datadir = /data/mysqldata/3306/data tmpdir = /data/mysqldata/3306/tmp open_files_limit = 512 explicit_defaults_for_timestamp sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #Buffer max_allowed_packet = 64M max_heap_table_size = 64M net_buffer_length = 8K sort_buffer_size = 2M join_buffer_size =4M read_buffer_size = 2M read_rnd_buffer_size = 16M #Log log-bin = /data/mysqldata/3306/binlog/mysql-bin binlog_cache_size = 16m max_binlog_cache_size = 128m max_binlog_size = 128m binlog_format = row log_output = FILE log-error = ../mysql-error.log slow_query_log = 1 slow_query_log_file = ../slow_query.log general_log = 0 general_log_file = ../general_query.log expire-logs-days = 14 #master-slave,这里先不做任何配置,下一个章节会讲到。 server-id = 1 binlog-ignore-db = test replicate-ignore-db = test log-slave-updates=true #InnoDB innodb_data_file_path = libdata1:1024M:autoextend innodb_log_file_size = 32M innodb_log_files_in_group =6 innodb_log_group_home_dir = /data/mysqldata/3306/redo-log/ innodb_buffer_pool_size = 200M sync_binlog = 8 #Undo Logs这里被我注释了,5.6版本undo可以拆分出来,用xtrabackup恢复有异常,就注释了。 #innodb_undo_directory = /data/mysqldata/3306/undo-log/ #innodb_undo_log = 64 #innodb_undo_tablespaces = 16 [mysql] no-auto-rehash prompt=(\\u@\\h) [\\d]>\\_
[root@DB servers]# ls mfs mysql-5.6.31 [root@DB servers]# ln -s mysql-5.6.31/ mysql [root@DB servers]# ll total 8 drwxr-xr-x. 6 root root 4096 Jun 30 21:31 mfs lrwxrwxrwx 1 root root 13 Aug 17 19:15 mysql -> mysql-5.6.31/ drwxr-xr-x 13 mysql mysql 4096 Aug 17 19:01 mysql-5.6.31
http://jiajinh.blog.51cto.com/2085098/1627966
# /app/servers/mysql-5.6.31/scripts/mysql_install_db --datadir=/data/mysqldata/3306/data --basedir=/app/servers/mysql-5.6.31
/app/servers/mysql-5.6.31/my.cnf,/app/servers/mysql-5.6.31/my-new.cnf,/etc/my.cnf,如果这些文件存在,可以清除掉。就发现warning消失了
启动数据库,我这里采用sale的方式启动:
[root@ok servers]# /app/servers/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf & [1] 25381 [root@ok servers]# 160818 21:58:55 mysqld_safe Logging to '/data/mysqldata/3306/data/../mysql-error.log'. 160818 21:58:56 mysqld_safe Starting mysqld daemon with databases from /data/mysqldata/3306/data
查看启动状态:
[root@ok log]# ps aux |grep mysqld root 25381 0.0 0.0 106232 1404 pts/0 S 21:58 0:00 /bin/sh /app/servers/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf mysql 25926 1.0 3.8 1088212 455204 pts/0 Sl 21:58 0:01 /app/servers/mysql-5.6.31/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --basedir=/app/servers/mysql-5.6.31 --datadir=/data/mysqldata/3306/data --plugin-dir=/app/servers/mysql-5.6.31/lib/plugin --user=mysql --log-error=/data/mysqldata/3306/data/../mysql-error.log --open-files-limit=512 --pid-file=/data/mysqldata/3306/mysql.pid --socket=/data/mysqldata/3306/mysql.sock --port=3306 root 26061 0.0 0.0 103308 876 pts/10 S+ 22:00 0:00 grep mysqld
[root@ok log]# /app/servers/mysql/bin/mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.32-log Source distribution Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. (root@localhost) [(none)]>
关闭数据库:
[root@ok log]# /app/servers/mysql/bin/mysqladmin -S /data/mysqldata/3306/mysql.sock shutdown
[root@ok log]# netstat -ano |grep 3306 [root@ok log]# ps -el|grep mysql
为保障安全性,修改root用户登录信息
(root@localhost) [mysql]> select user,password,host from user; +------+----------+-----------+ | user | password | host | +------+----------+-----------+ | root | | localhost | | root | | ok | | root | | 127.0.0.1 | | root | | ::1 | | | | localhost | | | | ok | +------+----------+-----------+ 6 rows in set (0.00 sec)
删除所有账户信息,只保留本地登录:
(root@localhost) [mysql]> delete from mysql.user where (user,host) not in (select 'root','localhost'); Query OK, 5 rows affected (0.00 sec)
(root@localhost) [mysql]> select user,password,host from user;
+------+----------+-----------+ | user | password | host | +------+----------+-----------+ | root | | localhost | +------+----------+-----------+ 1 row in set (0.00 sec)
联系方式QQ:326528263 EMAIL:clnking@163.com 网名:bass 分享技术 突破难点 创新思维