转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/44836547
一、在源码安装的基础上:我打了一个tar包:
cd /u01/myss06
tar cvzf my3306.tar .
二、关闭防火墙
chkconfig iptables off
service iptables stop
vi /etc/selinux/config
SELINUX=disabled
三、检查操作系统上是否安装了MySQL
[root@mydb1 backup]# rpm -qa |grep mysql
qt-mysql-4.6.2-26.el6_4.x86_64
mysql-5.1.71-1.el6.x86_64
mysql-server-5.1.71-1.el6.x86_64
mysql-devel-5.1.71-1.el6.x86_64
mysql-libs-5.1.71-1.el6.x86_64
四、删除MyQL(redhat6.3服务器自带的mysql-libs是mysql-libs-5.1.61-4.el6.x86_64,可能会和高版本的mysql-libs有冲突)
yum remove mysql-libs
五、确定MySQL相关包彻底删除
[root@mydb1 backup]# rpm -qa |grep mysql
六、添加用户和组:
id mysql
userdel -r mysql
groupadd mysql #增加用户组
useradd -d /home/mysql -g mysql mysql
七、配MySQL环境变量
su - mysql
vi .bash_profile
PATH=$PATH:$HOME/bin:/u01/my3306/bin
source .bash_profile
八、解压
cd /u01/my3306
tar -zxvf my3306.tar
九、在日志中会报RSA报如下错:
RSA private key file not found: /u01/my3306/data//private_key.pem. Some authentication plugins will not work.
RSA public key file not found: /u01/my3306/data//public_key.pem. Some authentication plugins will not work.
解决方法:
1. 检查是否安装openssl
$rpm -qa openssl
openssl-1.0.0-20.el6_2.5.x86_64
2.利用openssl生成公有和私有key
$ openssl genrsa -out mykey.pem 1024
Generating RSA private key, 1024 bit long modulus
..........++++++
.++++++
e is 65537 (0x10001)
$ openssl rsa -in mykey.pem -pubout -out mykey.pub
writing RSA key
$ ll mykey*
[root@mydb1 my3306]# ll mykey*
-rwxr-xr-x 1 root root 891 Apr 1 20:35 mykey.pem
-rwxr-xr-x 1 root root 272 Apr 1 20:35 mykey.pub
十、初始化MySQL脚本
./scripts/mysql_install_db --defaults-file=/u01/my3306/my.cnf --datadir=/u01/my3306/data --user=mysql
十一、启动mysql
vi .bash_profile ---root用户下添加
PATH=$PATH:$HOME/bin:/u01/my3306/bin
mysqld_safe --defaults-file=/u01/my3306/my.cnf --user=mysql &
[root@mydb3 ~]# su - mysql
[mysql@mydb3 ~]$ mysql -h127.0.0.1 -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.23-log Source distribution
Copyright (c) 2000, 2015, 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.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.15 sec)
mysql> show variables like '%log%';
+-----------------------------------------+-------------------------------------+
| Variable_name | Value |
+-----------------------------------------+-------------------------------------+
| back_log | 900 |
| binlog_cache_size | 32768 |
| binlog_checksum | CRC32 |
| binlog_direct_non_transactional_updates | OFF |
| binlog_error_action | IGNORE_ERROR |
| binlog_format | ROW |
| binlog_gtid_simple_recovery | OFF |
| binlog_max_flush_queue_time | 0 |
| binlog_order_commits | ON |
| binlog_row_image | FULL |
| binlog_rows_query_log_events | OFF |
| binlog_stmt_cache_size | 32768 |
| binlogging_impossible_mode | IGNORE_ERROR |
| expire_logs_days | 7 |
| general_log | OFF |
| general_log_file | /u01/my3306/data/mydb3.log |
| innodb_api_enable_binlog | OFF |
| innodb_flush_log_at_timeout | 1 |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_buffer_size | 67108864 |
| innodb_log_compressed_pages | ON |
| innodb_log_file_size | 1048576000 |
| innodb_log_files_in_group | 4 |
| innodb_log_group_home_dir | /u01/my3306/log/iblog |
| innodb_mirrored_log_groups | 1 |
| innodb_online_alter_log_max_size | 134217728 |
| innodb_undo_logs | 128 |
| log_bin | ON |
| log_bin_basename | /u01/my3306/log/binlog/binlog |
| log_bin_index | /u01/my3306/log/binlog/binlog.index |
| log_bin_trust_function_creators | OFF |
| log_bin_use_v1_row_events | OFF |
| log_error | /u01/my3306/log/alert.log |
| log_output | FILE |
| log_queries_not_using_indexes | ON |
| log_slave_updates | ON |
| log_slow_admin_statements | ON |
| log_slow_slave_statements | OFF |
| log_throttle_queries_not_using_indexes | 0 |
| log_warnings | 1 |
| max_binlog_cache_size | 2147483648 |
| max_binlog_size | 524288000 |
| max_binlog_stmt_cache_size | 18446744073709547520 |
| max_relay_log_size | 0 |
| relay_log | /u01/my3306/log/relaylog |
| relay_log_basename | /u01/my3306/log/relaylog |
| relay_log_index | /u01/my3306/log/relay.index |
| relay_log_info_file | /u01/my3306/log/relay-log.info |
| relay_log_info_repository | FILE |
| relay_log_purge | ON |
| relay_log_recovery | OFF |
| relay_log_space_limit | 0 |
| simplified_binlog_gtid_recovery | OFF |
| slow_query_log | ON |
| slow_query_log_file | /u01/my3306/log/slow.log |
| sql_log_bin | ON |
| sql_log_off | OFF |
| sync_binlog | 100 |
| sync_relay_log | 10000 |
| sync_relay_log_info | 10000 |
+-----------------------------------------+-------------------------------------+
61 rows in set (0.02 sec)
***********************************************************************************************************
在安装过程可能会报错,一般看日志
tail -f /u01/my3306/log/alert.log
在执行:mysqld_safe --defaults-file=/u01/my3306/my.cnf --user=mysql &
1、报错1:
2015-04-02 19:18:00 4201 [Note] RSA private key file not found: /u01/my3306/data//private_key.pem. Some authentication plugins will not work.
解决:
修改my.cnf中的配置,把下面两行注释掉
[mysqld]
#sha256_password_private_key_path=/u01/my3306/mykey.pem
#sha256_password_public_key_path=/u01/my3306/mykey.pub
2、再执行mysqld_safe --defaults-file=/u01/my3306/my.cnf --user=mysql &
报错2:
2015-04-02 19:23:36 6109 [ERROR] Can't find messagefile '/u01/my3306/share/mysql/errmsg.sys'
将源码包里面的/bak/share/english/errmsg.sys复制到/u01/my3306/share/mysql/errmsg.sys
scp /bak/share/english/errmsg.sys 192.168.1.18:/u01/my3306/share/mysql/errmsg.sys
搞定!!!!