Mysql5.6.23 安装

  1. 下载mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
  2. 上传到linux服务器rz mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
  3. 解压缩 tar -zxvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
  4. 建立软连接 :ln -s /usr/local/mysql-5.6.23-linux-glibc2.5-x86_64 /usr/local/mysql
  5. 创建用户用户组:groupadd -g 101 dba,useradd mysqladmin
  6. 修改用户的用户组:usermod -g dba -G dba,root mysqladmin
    [root@hadoop local]# id mysqladmin
    uid=1003(mysqladmin) gid=101(dba) groups=101(dba),0(root)
  7. 修改用户mysqladmin的密码:passwd mysqladmin
  8. 修改mysql安装文件的用户和用户组:chown -R mysqladmin:dba /usr/local/mysql-5.6.23-linux-glibc2.5-x86_64,修改软连接的所属用户和用户组chown -R mysqladmin:dba /usr/local/mysql,chown -R mysqladmin:dba /usr/local/mysql/*
    在这里插入图片描述
  9. 修改权限:chmod -R 755 /usr/local/mysql-5.6.23-linux-glibc2.5-x86_64,修改软连接的权限chmod -R 755 /usr/local/mysql,chmod -R 755 /usr/local/mysql/*
    在这里插入图片描述
  10. 创建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

#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 = 1024M
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
  1. 修改my.cnf的所属用户和用户组以及权限:chown mysqladmin:dba /etc/my.cnf,chmod 640 /etc/my.cnf
  2. 切换用户:su - mysqladmin,cd /usr/local/mysql,创建:mkdir arch backup
  3. 切回到root用户:查看版本号cat /proc/version,
  4. 查看有没有安装gcc:rpm -qa |grep gcc,没有安装yum install -y gcc
  5. 安装yum install -y libaio,yum install -y perl
  6. 在mysqladmin用户下的/usr/local/mysql目录下执行安装mysql脚本
scripts/mysql_install_db  \
--user=mysqladmin \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data

提示缺少:

FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper

需要安装:yum -y install autoconf
出现如下安装成功:

Installing MySQL system tables...2019-11-23 11:16:37 0 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2019-11-23 11:16:37 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
OK

Filling help tables...2019-11-23 11:17:15 0 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
2019-11-23 11:17:15 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
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/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql/bin/mysqladmin -u root -h hadoop password 'new-password'

Alternatively you can run:

  /usr/local/mysql/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/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 at http://bugs.mysql.com/

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

New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

启动mysql

  1. 在root用户下,拷贝cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql
  2. 赋予可执行权限:chmod +x /etc/rc.d/init.d/mysql
    在这里插入图片描述
  3. 删除开机启动服务:chkconfig --del mysql
  4. 添加服务,并且修改为开机启动:chkconfig --add mysql,chkconfig --level 345 mysql on(开机自启动不起作用)
  5. 需要手动启动:vi /etc/rc.local,最后一行添加su - mysqladmin -c “/etc/init.d/mysql start --federated”
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
#添加自启动
su - mysqladmin -c "/etc/init.d/mysql start --federated"
  1. 切换用户:su - mysqladmin
  2. 删除/usr/local/mysql目录下的my.cnf文件:rm -rf /usr/local/mysql/my.cnf
  3. 执行bin/mysqld_safe &
  4. ps -ef|grep mysqld
  5. netstat -tulnp | grep mysql
    在这里插入图片描述
  6. 在root用户下查看mysql的运行状态
[root@hadoop support-files]#  service mysql status
 SUCCESS! MySQL running (25246)
[root@hadoop support-files]# 

以上表示mysql运行成功

登录mysql

在mysqladmin用户的/usr/local/mysql目录下执行:bin/mysql
在这里插入图片描述

mysql用户操作命令

  1. use mysql;
  2. 修改密码:update user set password=password(‘password’) where user=‘root’;
  3. 删除用户:delete from user where user=’’;
  4. 查询所有用户: select host,user,password from user;
  5. 配置某台服务器访问mysql的user+password权限
 grant all privileges on *.* to root@'%' identified by 'mysqladmin'; 
 flush privileges;
 # %表示任意ip
  1. 刷新权限:flush privileges;
  2. 配置环境变量
 [mysqladmin@hadoop ~]$ vi .bashrc 
 [mysqladmin@hadoop ~]$ source .bashrc

在这里插入图片描述
用which查看下,是否生效

[mysqladmin@hadoop ~]$ which mysql
/usr/local/mysql/bin/mysql

部署出了问题重新部署

  1. 检查用户和目录有些命令是在root下执行,有些是mysqladmin下执行
  2. 重新部署:rm -rf arch/* data/* ,其中arch目录下是备份data下数据的二进制文件
  3. 执行脚本
scripts/mysql_install_db  \
--user=mysqladmin \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值