MySQL二进制部署

我的mysql选择安装在/usr/local

    [root@localhost ~]# cd /usr/local/

    [root@localhost local]# rz
    rz waiting to receive.
    Starting zmodem transfer.  Press Ctrl+C to cancel.
      100%  304464 KB 27678 KB/s 00:00:11       0 Errorsgz...

    [root@localhost local]# 

(rz上传如果不能使用 yum install -y lrzsz)

上传以后ll看是否存在。

[root@localhost local]# ll
总用量 304468
drwxr-xr-x. 2 root root         6 4月  11 12:59 bin
drwxr-xr-x. 2 root root         6 4月  11 12:59 etc
drwxr-xr-x. 2 root root         6 4月  11 12:59 games
drwxr-xr-x. 2 root root         6 4月  11 12:59 include
drwxr-xr-x. 2 root root         6 4月  11 12:59 lib
drwxr-xr-x. 2 root root         6 4月  11 12:59 lib64
drwxr-xr-x. 2 root root         6 4月  11 12:59 libexec
-rw-r--r--. 1 root root 311771412 7月  26 16:33 mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 2 root root         6 4月  11 12:59 sbin
drwxr-xr-x. 5 root root        49 7月  25 13:30 share
drwxr-xr-x. 2 root root         6 4月  11 12:59 src
[root@localhost local]#

查看是否有mysql进程,是否安装过mysql

[root@localhost local]# ps -ef|grep mysql
root       2535   1992  0 16:57 pts/0    00:00:00 grep --color=auto mysql
[root@localhost local]# rpm -qa |grep -i mysql
[root@localhost local]#

很明显没有~~

解压

tar xzvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz

重命名

mv mysql-5.6.23-linux-glibc2.5-x86_64 mysql

 

 

添加mysql用户

添加dba组,gid=101

groupadd -g 101 dba

添加一个用户mysqladmin,uid=514 所在组=dba,root 指定家目录=/usr/local/mysql

useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin

查看该用户信息

id mysqladmin

copy 环境变量配置文件至mysqladmin用户的home目录中(为下面配置个人环境变量做准备)

cp /etc/skel/.* /usr/local/mysql

创建my.cnf

vi /etc/my.cnf

配置如下

  

  [client] port = 3306 socket = /usr/local/mysql/data/mysql.sock [mysqld] port = 3306 socket = /usr/local/mysql/data/mysql.sock skip-external-locking key_buffer_size = 256M sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 4M query_cache_size= 32M max_allowed_packet = 16M myisam_sort_buffer_size=128M tmp_table_size=32M table_open_cache = 512 thread_cache_size = 8 wait_timeout = 86400 interactive_timeout = 86400 max_connections = 600 # Try number of CPU's*2 for thread_concurrency thread_concurrency = 32 #isolation level and default engine default-storage-engine = INNODB transaction-isolation = READ-COMMITTED server-id = 1 basedir = /usr/local/mysql datadir = /usr/local/mysql/data pid-file = /usr/local/mysql/data/hostname.pid #open performance schema log-warnings sysdate-is-now binlog_format = MIXED log_bin_trust_function_creators=1 log-error = /usr/local/mysql/data/hostname.err log-bin=/usr/local/mysql/arch/mysql-bin #other logs #general_log =1 #general_log_file = /usr/local/mysql/data/general_log.err #slow_query_log=1 #slow_query_log_file=/usr/local/mysql/data/slow_log.err #for replication slave #log-slave-updates #sync_binlog = 1 binlog_format = MIXED log_bin_trust_function_creators=1 log-error = /usr/local/mysql/data/hostname.err log-bin=/usr/local/mysql/arch/mysql-bin #other logs #general_log =1 #general_log_file = /usr/local/mysql/data/general_log.err #slow_query_log=1 #slow_query_log_file=/usr/local/mysql/data/slow_log.err #for replication slave #log-slave-updates #sync_binlog = 1 #for innodb options innodb_data_home_dir = /usr/local/mysql/data/ innodb_data_file_path = ibdata1:500M:autoextend innodb_log_group_home_dir = /usr/local/mysql/arch innodb_log_files_in_group = 2 innodb_log_file_size = 200M innodb_buffer_pool_size = 2048M innodb_additional_mem_pool_size = 50M innodb_log_buffer_size = 16M innodb_lock_wait_timeout = 100 #innodb_thread_concurrency = 0 innodb_flush_log_at_trx_commit = 1 innodb_locks_unsafe_for_binlog=1 #innodb io features: add for mysql5.5.8 performance_schema innodb_read_io_threads=4 innodb-write-io-threads=4 innodb-io-capacity=200 #purge threads change default(0) to 1 for purge innodb_purge_threads=1 innodb_use_native_aio=on #case-sensitive file names and separate tablespace innodb_file_per_table = 1 lower_case_table_names=1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [mysqlhotcopy] interactive-timeout [myisamchk] key_buffer_size = 256M sort_buffer_size = 256M read_buffer = 2M write_buffer = 2M

修改my.cnf权限

chown mysqladmin:dba /etc/my.cnf

chmod 640 /etc/my.cnf

ll /etc/my.cnf

 修改mysql文件夹权限

chown -R mysqladmin:dba /usr/local/mysql

chmod -R 755 /usr/local/mysql

创建归档文件夹

mkdir arch

下载libaio包

su - root

cat  /proc/version

rpm -qa |grep gcc

yum -y install libaio

切换至mysqladmin,进行安装

su - mysqladmin

scripts/mysql_install_db --user=mysqladmin --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

 

如遇下图所示错误则需要安装autoconf库(需要切换root用户执行或者sudo)

yum -y install autoconf   //此包安装时会安装Data:Dumper模块

 

 设置开机启动

su - root

cd /usr/local/mysql

将服务文件拷贝到init.d下,并重命名为mysql

cp  support-files/mysql.server   /etc/rc.d/init.d/mysql

增加执行权限

chmod +x /etc/rc.d/init.d/mysql

设置开机启动

chkconfig –del mysql ##初次安装不需要删除服务

添加服务

chkconfig –add mysql

chkconfig –level 345 mysql on

开启mysql,

su - mysqladmin

rm  -f my.cnf

启动

bin/mysqld_safe &   ##启动完按回车

查看进程和端口号

ps -ef|grep mysqld

netstat -nlp | grep mysqld

 

登陆

初次登陆root可以不输入密码,修改mysql里的user表密码即可登陆

 

转载于:https://www.cnblogs.com/pipipi/p/9373723.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值