我这里下载的是mysql-5.5.53-linux2.6-x86_64.tar.gz
1.创建mysql用户和用户组
#groupadd mysql
#useradd -g mysql mysql
#passwd mysql
2.下载解压二进制文件,解压,进入解压出来的文件
[root@host01 db]# tar -xvf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
[root@host01 db]# mv mysql-5.6.34-linux-glibc2.5-x86_64 mysqlmha
3.在mysqlmha目录下创建如下文件夹
[mysql@host01 mysqlmha]$ cd /db/mysqlmha
[mysql@host01 mysqlmha]$ mkdir data ##数据文件目录
[mysql@host01 mysqlmha]$ mkdir conf ## 配置文件目录
[mysql@host01 mysqlmha]$ mkdir redolog ##redo日志文件
[mysql@host01 mysqlmha]$ mkdir ibdata ##ibdata文件
[mysql@host01 mysqlmha]$ mkdir -p mysqllog/relaylog ##主从环境relaylog
[mysql@host01 mysqlmha]$ mkdir -p mysqllog/logfile ##错误日志文件
[mysql@host01 mysqlmha]$ mkdir -p mysqllog/binlog ##binlog文件
4.创建配置文件
在conf目录下创建配置文件my.cnf,配置文件内容附后.
5.更改文件夹mysqlmha的文件所属用户
[root@host01 db]# chown -R mysql:mysql mysqlmha
6.安装数据库
[root@host01 db]#cd /db/mysqlmha/scripts
[root@host01 db]#./mysql_install_db --user=mysql --basedir=/db/mysqlmha --datadir=/db/mysqlmha/data
7.创建软连接
[root@host01 db]# mkdir -p /usr/local/mysql/bin
[root@host01 db]# ln -s /db/mysqlmha/bin/mysqld /usr/local/mysql/bin/mysqld
8.启动数据库
[root@host01 db]#./mysqld_safe --defaults-file=/db/mysqlmha/conf/my.cnf --user=mysql
9.登陆数据库修改密码
5.5版本在创建数据库的时候,root账号的密码默认为空,不需要密码即可登陆数据库,为了安全起见,我们登陆数据后要修改密码
[root@host01 db]$./mysql -h localhost -u root -S /db/mysqlmha/data/mysql.sock
update mysql.user set password=PASSWORD('mysql') where user='root' and host='localhost';
flush privileges;
10.关闭数据库后重启
[mysql@host01 bin]$ ./mysqladmin -h localhost -u root -p -S /db/mysqlmha/data/mysql.sock shutdown
[mysql@host01 bin]$./mysqld_safe --defaults-file=/db/mysqlmha/conf/my.cnf --user=mysql
my.cnf文件内容:
[mysql@host01 conf]$ more my.cnf
[mysqld]
port=3306
server-id=1
datadir=/db/mysqlmha/data
socket=/db/mysqlmha/data/mysql.sock
character-set-server=utf8
max_connections = 1500
skip-external-locking
key_buffer_size=16M
max_allowed_packet=16M
myisam_sort_buffer_size=16M
query_cache_size=32M
read_buffer_size=2M
sort_buffer_size=2M
#table_cache=512
#thread_cache=20
#thread_concurrency=4
interactive_timeout=86400
wait_timeout=86400
#log_slow_queries=1
innodb_file_per_table=1
#innodb_additional_mem_pool_size=16M
innodb_buffer_pool_size=128M
innodb_data_home_dir=/db/mysqlmha/ibdata
innodb_data_file_path=ibdata1:100M;ibdata2:100M;ibdata3:100M;ibdata4:100M:autoextend
##这两个参数可以不用指定,要是指定的话,系统启动后会生成ibdata1,ibdata2..4,包括重新生成ibdata1,数据库刚安装的时候系统信息表全部是保留在ibdata1里的,这样的话,这些系统表就会提示不存在.
#innodb_file_io_threads=4
innodb_flush_log_at_trx_commit=2
innodb_lock_wait_timeout=50
innodb_log_buffer_size=128M
innodb_log_file_size=128M
innodb_log_files_in_group=5
innodb_log_group_home_dir=/db/mysqlmha/redolog
innodb_thread_concurrency=8
log_bin_trust_function_creators=1
event_scheduler=1
max_binlog_size=100M
log-bin=/db/mysqlmha/mysqllog/binlog/binlog.bin
slow_query_log_file=/db/mysqlmha/mysqllog/logfile/slow-query.log
long_query_time=1
log-error=/db/mysqlmha/mysqllog/logfile/mysql-err.log
binlog_format=mixed
expire_logs_days=7
binlog_cache_size=4MB
skip-host-cache
skip-name-resolve
#read-only
skip-slave-start
relay-log-index=/db/mysqlmha/mysqllog/relaylog/slave-relay-bin.index
relay-log=/db/mysqlmha/mysqllog/relaylog
replicate-ignore-db=information_schema,performance_schema
slave_net_timeout=60
log_slave_updates=1
##lower_case_table_names=1
lc-messages-dir=/db/mysqlmha/share
##language=/db/mysqlmha/share/english
-- The End --
阅读(3728) | 评论(0) | 转发(0) |