mysql-5.6.13-3308-源码安装

一、卸载旧版本:
使用下面的命令检查是否安装有MySQL Server
rpm-qa | grep mysql
有的话通过下面的命令来卸载掉
rpm -e –nodeps mysql // 强力删除模式

二、创建MySQL属组、用户
groupadd mysql
useradd -g mysql mysql

安装Mysql
安装编译代码需要的包
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
下载mysql-5.6.13.tar.gz wget -c http://cdn.mysql.com//archives/mysql-5.6/mysql-5.6.13.tar.gz
tar –zxvf mysql-5.6.13.tar.gz
cd mysql-5.6.13
编译安装
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/db3308 \
-DMYSQL_DATADIR=/data/mysqldata/data3308 \
-DSYSCONFDIR=/usr/local/mysql/db3308/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3308 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

make && make install
整个过程需要30分钟左右……漫长的等待

三、配置Mysql
设置权限
进入安装目录
cd/usr/local/mysql/db3308
[root@DBServer1 db3308]# cp support-files/my-default.cnf /usr/local/mysql/db3308/my.cnf ##为mysql提供配置文件
[root@DBServer1 db3308]# vi /usr/local/mysql/db3308/my.cnf ##修改配置文件
[root@DBServer1 db3308]# cat /usr/local/mysql/db3308/my.cnf
cat << EOF >/usr/local/mysql/db3308/my.cnf
[client]
port = 3308
socket = /tmp/mysql.sock

[mysqld]
port = 3308
socket = /tmp/mysql.sock
basedir = /usr/local/mysql/db3308
datadir = /data/mysqldata/data3308
server_id = 38
log_bin=mysql-bin-master
event_scheduler = 1

lower_case_table_names=1
character_set_server=utf8

join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
innodb_log_file_size=256M
innodb_file_per_table=1

#The Mysqlserver master

#########-basic-##################

skip-external-locking
skip-name-resolve
default-storage-engine = INNODB
wait_timeout = 28800
connect_timeout = 10
interactive_timeout = 28800
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

###########semi_replication########
#rpl_semi_sync_master_enabled=1
#rpl_semi_sync_master_timeout=5000

######—binlog—###############

#log-bin = /mysqllog/binlog/mysql-bin-master
binlog_format = mixed

######################

binlog-ignore-db=mysql
binlog-ignore-db=percona
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
binlog-do-db=mxd_db10
binlog-do-db=minxindai_2

max_binlog_size = 1024M
binlog_cache_size = 16M
expire-logs-days = 30

########-slow Query log-################
slow_query_log_file = /mysqllog/slowlog/slow.log
slow_query_log = 1
long_query_time = 5

######-Error Logs-#######################
#log-error = /mysqllog/errorlog/mysql.localhost.err
#log_error = /mysqllog/errorlog/mysql.err
log_error = /usr/local/mysql/errorlog/mysql.err
relay_log_recovery = 1

############################

innodb_flush_log_at_trx_commit = 1

###########################
max_connections=5000
key_buffer = 32M
key_buffer_size = 64M
max_allowed_packet = 64M
table_definition_cache = 4096
net_buffer_length = 8K
myisam_sort_buffer_size = 8M
tmp_table_size = 64M
max_heap_table_size = 64M

#######################
query_cache_type=1
query_cache_size = 32M
query_cache_limit = 2M

###################
open_files_limit = 10240
transaction_isolation = READ-COMMITTED
thread_concurrency = 16

innodb_file_per_table = 1
#innodb_data_home_dir=/data/mysqldata
#innodb_log_group_home_dir=/mysqllog/logs
#innodb_data_file_path = ibdata1:100M:autoextend

innodb_buffer_pool_size=4G
innodb_buffer_pool_instances=8
innodb_additional_mem_pool_size=16M

innodb_log_file_size=1024M
innodb_log_buffer_size=64M
innodb_log_files_in_group=3
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 10

innodb_sync_spin_loops=40
innodb_max_dirty_pages_pct=90
innodb_thread_concurrency = 16

innodb_thread_sleep_delay=500
innodb_file_io_threads=4
innodb_concurrency_tickets=1000

log_bin_trust_function_creators=1
innodb_flush_method=O_DIRECT

innodb_file_per_table = 1
innodb_read_io_threads=16
innodb_write_io_threads=16
innodb_file_format=Barracuda

innodb_purge_threads=1
innodb_purge_batch_size=32
innodb_old_blocks_pct=75

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysqldump]
quick
max_allowed_packet=32M
myisam_max_sort_file_size=10G

[mysql]
auto-rehash

[myisamchk]
key_buffer_size=64M
sort_buffer_size=1M
read_buffer=2M
write_buffer=2M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
open-files-limit=2819
EOF

四、设置MySQL属组属组权限:
mkdir /data/mysqldata/data3308 -p ###创建MySQL数据库存储目录
mkdir /usr/local/mysql/errorlog -p ###创建MySQL数据错误日志目录
chown -R mysql.mysql /usr/local/mysql ##设置MySQL属组属组目录

进入安装路径,执行初始化配置脚本,创建系统自带的数据库和表
cd scripts && ./mysql_install_db –user=mysql –basedir=/usr/local/mysql/db3308 –datadir=/data/mysqldata/data3308 &

初始化后,出现如下字样:(可以忽略)
2016-12-13 11:53:21 1865 [Note] InnoDB: 5.6.13 started; log sequence number 1625977
2016-12-13 11:53:22 1865 [Note] Binlog end
2016-12-13 11:53:22 1865 [Note] InnoDB: FTS optimize thread exiting.
2016-12-13 11:53:22 1865 [Note] InnoDB: Starting shutdown…
2016-12-13 11:53:23 1865 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/db3308/bin/mysqladmin -u root password ‘new-password’
/usr/local/mysql/db3308/bin/mysqladmin -u root -h 10.0.10.9 password ‘new-password’

Alternatively you can run:

/usr/local/mysql/db3308/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd . ; /usr/local/mysql/db3308/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /usr/local/mysql/db3308/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used –defaults-file)
and when you later start the server.
The new default config file was created as /usr/local/mysql/db3308/my-new.cnf,
please compare it with your file and take the changes you need.

五、启动检查MySQL服务是否正常!!!
/usr/local/mysql/db3308/bin/mysqld_safe

配置用户
MySQL启动成功后,root默认没有密码,需要设置root密码。
/usr/local/mysql/db3308/bin/mysqladmin -uroot password ‘mysqlDBserver_123$%’ -S /tmp/mysql.sock

六、设置之前,我们需要先设置PATH,要不不能直接调用mysql
cat << EOF >/etc/profile.d/mysql.sh
PATH=/usr/local/mysql/db3306/bin:$PATH
export PATH
EOF

配置全局立即生效
source /etc/profile

七、添加服务,拷贝服务脚本到init.d目录,并设置开机启动
[root@DBServer1 db3308]# cp -fr /usr/local/mysql/db3308/support-files/mysql.server /etc/init.d/mysqld
[root@DBServer1 db3308]# chkconfig mysqld on
service mysql start或者/etc/init.d/mysqld start –启动MySQL

9、设置密码

方式一:

# mysqladmin -uroot password 要设置的密码(加不加引号都可以)

或者
# mysqladmin -u用户名 -p旧密码 password 新密码(加不加引号都可以)

方式二:

mysql> update mysql.user set password=PASSWORD(‘要设置的密码’) where user=’root’;

mysql> flush privileges; # 刷新数据库权限

10、创建用户

1)创建用户

mysql> create user ‘用户名’@’%’ identified by ‘密码’;

2)创建用户并授权

mysql> grant all on . to 用户名@’%’;

mysql> flush privileges;# 刷新数据库权限

若要设置root用户可以远程访问,执行
grant all on . to root@”%” identified by”Huawei_123”;
flush privileges;
配置防火墙
防火墙的3308端口默认没有开启,若要远程访问,需要开启这个端口

打开/etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p -dport 3308 -j ACCEPT
然后保存,并关闭该文件,在终端内运行下面的命令,刷新防火墙配置:
service iptables restart
OK,一切配置完毕,你可以访问你的MySQL了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值