mysql5.6 二进制免编译安装

时间:2022-09-12 21:03:49

原文出自http://www.ttlsa.com/mysql/install-mysql5_6/

1. 安装必要的组件

yum install –y autoconf automake imake libxml2-devel\ expat-develcmakegccgcc-c++libaiolibaio-develbzrbisonlibtoolncurses5-devel

2. 下载解压mysql软件

2345 # cd /usr/local/src# wget -c http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz/from/http://cdn.mysql.com/ -O mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz# tar zxvf mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz –C ../# cd /usr/local/# ln -s mysql-5.6.14-linux-glibc2.5-x86_64 mysql

3. 创建Mysql用户组和用户,及数据库存放目录:

1234567 # mkdir -p /data/mysql_data_3306# mkdir -p /data/mysql_log# mkdir -p /data/log-bin# groupadd mysql# useradd mysql -g mysql -M -s /sbin/nologin# chown -R mysql.mysql /data/mysql_data_3306 /data/mysql_log /data/log-bin# chown -R mysql.mysql /usr/local/mysql-5.6.14-linux-glibc2.5-x86_64

4. 配置文件(依具体环境)

# vi /etc/my.cnf

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 [mysqld]# GENERAL #user=mysqldefault-storage-engine=InnoDBsocket=/data/mysql_data_3306/mysql.sockpid-file=/data/mysql_data_3306/mysql.pidport=3306# MyISAM #key_buffer_size=1344Mmyisam_recover=FORCE,BACKUP# SAFETY #max_allowed_packet=16Mmax_connect_errors=1000000skip_name_resolve# DATA STORAGE #datadir=/data/mysql_data_3306/long_query_time=1# BINARY LOGGING #log-bin=/data/log-bin/mysql-bin-3306expire-logs-days=14sync-binlog=1server-id=1max_binlog_size=500M# REPLICATION #relay-log=/data/log-bin/relay-bin-3306slave-net-timeout=60# CACHES AND LIMITS #tmp_table_size=32Mmax_heap_table_size=32Mmax_connections=500thread_cache_size=50open_files_limit=65535table_definition_cache=4096table_open_cache=4096# INNODB #innodb_data_file_path=ibdata1:128M;ibdata2:10M:autoextendinnodb_flush_method=O_DIRECTinnodb_log_files_in_group=2innodb_lock_wait_timeout=50innodb_log_file_size=256Minnodb_flush_log_at_trx_commit=1innodb_file_per_table=1innodb_thread_concurrency=8innodb_buffer_pool_size=8G# LOGGING #log-error=/data/mysql_log/mysql-error-3306.loglog-queries-not-using-indexes=1slow-query-log=1long_query_time=1slow-query-log-file=/data/mysql_log/mysql-slow-3306.log# FOR SLAVE ##binlog-format = ROW#log-slave-updates = true#gtid-mode = on#enforce-gtid-consistency = true#master-info-repository = TABLE#relay-log-info-repository = TABLE#sync-master-info = 1#slave-parallel-workers = 2#binlog-checksum = CRC32#master-verify-checksum = 1#slave-sql-verify-checksum = 1#binlog-rows-query-log_events = 1#report-port = 3306#report-host = 10.1.1.10

5. 系统服务

12345678910 # cp -af /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld_3306# vi /etc/init.d/mysqld_3306修改两处位置:basedir=/usr/local/mysqldatadir=/data/mysql_data_3306 执行如下命令# chmod 755 /etc/init.d/mysqld_3306# chkconfig --add mysqld_3306# chkconfig --level 345 mysqld_3306 on

 

6. 初始化数据库

12 # cd /usr/local/mysql# ./scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf

7. 启动数据库进程

1 # service mysqld_3306 start

8. 修改root密码

1234 # /usr/local/mysql/bin/mysql -p -uroot -S /tmp/mysql.sock #这里直接回车就能进入数据库系统Mysql>deletefrommysql.userwhereuser='';Mysql>updatemysql.usersetpassword=PASSWORD(xxxxxxxx)whereuser='root';Mysql>flushprivileges;

 ln -s /usr/local/mysql/bin/mysql /usr/bin


mysql --socket=/tmp/mysql.sock
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


/etc/my.cnf里的socket路径