Mysql-5.6-快速安装

安装MYSQLmysql

本人安装的系统版本信息(Esxi虚拟机)
[lsug@172-16-1-105 ~]$ uname -a
Linux 172-16-1-105 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[lsug@172-16-1-105 ~]$ cat /etc/redhat-release 
CentOS release 6.7 (Final)linux

一,编译安装所需的工具和库
yum install gcc gcc-c++ ncurses-devel perl cmake  -yc++


二,新增mysql用户和组
useradd mysql -s /sbin/nologin -M sql

三,下载软件并安装
下载
wget http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.34.tar.gzvim

解压
tar -zxf mysql-5.6.34.tar.gz
cd mysql-5.6.34
编译
cmake . -DCMAKE_INSTALL_PREFIX=/data/mysql \
-DMYSQL_DATADIR=/data/mysql/data \
-DMYSQL_UNIX_ADDR=/data/mysql/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLIATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0socket


make  && make install工具

编译my.cnf(这是咱们的开发测试环境配置的参数,你能够根据本身的环境调试)
vim /etc/my.cnf测试

[mysqld]
port            = 3306
socket          = /data/mysql/tmp/mysql.sock
datadir         = /data/mysql/data
user            = mysql
server_id=38253
replicate_wild_ignore_table     = db_check.%
replicate_wild_ignore_table     = information_schema.%
replicate_wild_ignore_table     = performance_schema.%
back_log = 500
max_connections = 4500
max_user_connections = 3000
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
max_connect_errors = 50000
#character_set_filesystem = utf8
collation_server = utf8_bin
character_set_server = utf8
interactive_timeout = 31536000
wait_timeout = 50400
skip_name_resolve = 1
innodb_file_per_table = 1
table_open_cache = 4096
table_definition_cache = 4096
max_allowed_packet = 16M
#binlog_cache_size = 2M
#binlog_stmt_cache_size = 1M
#binlog_rows_query_log_events = 1
max_heap_table_size = 64M
tmp_table_size = 64M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 64
####thread_concurrency = 16
thread_stack = 256K
#query_cache_size = 64M
#query_cache_type = 0
#query_cache_limit = 2M
ft_min_word_len = 4
default-storage-engine = INNODB
transaction_isolation = REPEATABLE-READ
#log-bin = /data/mysql/data/binlog
#relay_log = /data/mysql/data/relaylog
binlog_format = row
expire_logs_days = 30
log_slave_updates
slow_query_log
long_query_time = 1
key_buffer_size = 32M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
#innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 32G
innodb_data_file_path = ibdata1:1G:autoextend
#innodb_write_io_threads = 4
#innodb_read_io_threads = 2
#innodb_thread_concurrency = 8
innodb_thread_concurrency = 64
innodb_flush_log_at_trx_commit = 0
#sync_binlog = 0
innodb_log_buffer_size = 8M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 75
innodb_lock_wait_timeout = 10
innodb_old_blocks_time= 1000
innodb_stats_on_metadata = 0
tmpdir = /data/mysql/tmpui

#thread_pool_oversubscribe = 8
#slave_parallel_threads = 8
#innodb_buffer_pool_instances = 4
innodb_buffer_pool_dump_at_shutdown = 1
innodb_buffer_pool_load_at_startup = 1
####extra_max_connections = 10
####extra_port = 33061
innodb_print_all_deadlocks = 1
#innodb_io_capacity = 4000
innodb_io_capacity = 2000
#innodb_flush_method = O_DIRECT
innodb_file_format = Barracuda
#innodb_flush_neighbors = 0
#innodb_lru_scan_depth = 2048
#slave-skip-errors=1062
explicit_defaults_for_timestamp=1es5

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
prompt="\\u@\\h:\\d \\R:\\m:\\s> "
default-character-set = utf8

[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
open-files-limit = 8192
--------------------------

mkdir -p /data/mysql/tmp/

修改权限文件
chown -R mysql.mysql /data/mysql
进入安装路径,执行初始化配置脚本

cd /data/mysql
./scripts/mysql_install_db --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data/
注:在启动MySQL服务时,会按照必定次序搜索my.cnf,
先在/etc目录下找,找不到则会搜索"$basedir/my.cnf",
在本例中就是,本人放置在/etc/my.cnf
注意:在CentOS 6.4版操做系统的最小安装完成后,在/etc目录下会存在一个my.cnf,须要将此文件改名为其余的名字,如:/etc/my.cnf.bak,不然,该文件会干扰源码安装的MySQL的正确配置,形成没法启动。

 

添加服务,拷贝服务脚本到init.d目录,并设置开机启动
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on

启动msyql并检查状态
[root@localhost mysql]# /etc/init.d/mysql start
Starting MySQL........ SUCCESS! 
[root@localhost mysql]# /etc/init.d/mysql status
 SUCCESS! MySQL running (32356)
 


MySQL启动成功后,root默认没有密码,咱们须要设置root密码。
设置以前,咱们须要先设置PATH,要否则不能直接调用mysql
修改/etc/profile文件,在文件末尾添加
export PATH=/data/mysql/bin:$PATH
 

让配置当即生效
source /etc/profile
如今,咱们能够在终端内直接输入mysql,进入mysql的环境了

执行下面的命令修改root密码
mysql -uroot  
mysql> SET PASSWORD = PASSWORD('123456');

若要设置root用户能够远程访问,执行
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

 


-----------编译报错解决------(网上搜集)----------
1.若make出现相似错误:
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".
CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
代表make未安装,执行:sudo apt-get install -y make
参见: Mysql 错误以及解决办法

2.若是make到63%左右出现错误:
make[2]: *** [storage/perfschema/unittest/pfs_connect_attr-t] Error 1
make[1]: *** [storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/all] Error 2
则:cmake去掉-DWITH_PARTITION_STORAGE_ENGINE=1参数从新编译
参见: 通用MYSQL5.5和5.6源码包安装

3.MySQL启动报错:
[ERROR] InnoDB: The system tablespace must be writable!
[ERROR] Plugin 'InnoDB' init function returned error.
则:rm -rf /usr/local/mysql/data/ib_logfile*
编译参数及安装过程: Linux源码安装mysql 5.6.12 (cmake编译)

4.其余错误: Ubuntu 12 下的Mysql 5.5的 cmake 源码编译安装
5.编译错误:configure: error: No curses/termcap library found
查找文件系统:find / -name libncursesw*
若是找到则从新编译并加上如下参数:
--with-named-curses-libs=/lib/i386-linux-gnu/libncursesw.so.5.9

或者安装libncurses5-dev包:
sudo apt-cache search libncurses5 && sudo apt-get install -y libncurses5-dev

6.make出现错误:collect2: ld returned 1 exit status 尝试以下解决方案: sudo apt-get install -f sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install -f build-essential libncurses5-dev libncurses5

相关文章
相关标签/搜索