1.下载
下载路径:https://dev.mysql.com/downloads/mysql/5.7.html
2.把Mysql放到Linux机器里面
[root@xkhadoop local]# tar -xzvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
[root@xkhadoop local]# pwd
/usr/local
[root@xkhadoop local]# ll
总用量 777932
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x. 9 root root 129 11月 24 15:47 mysql-5.7.28-linux-glibc2.12-x86_64
-rw-r--r--. 1 root root 760637440 11月 24 15:18 mysql-5.7.28-linux-glibc2.12-x86_64.tar
-rw-r--r--. 1 7161 31415 35959399 9月 27 16:58 mysql-test-5.7.28-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 11月 10 22:37 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
3.创建mysql用户,并修改Mysql文件权限
[root@xkhadoop local]# useradd mysql
[root@xkhadoop local]# id mysql
uid=1003(mysql) gid=1003(mysql) 组=1003(mysql)
[root@xkhadoop local]# chown mysql:mysql mysql-5.7.28-linux-glibc2.12-x86_64
[root@xkhadoop local]# chown mysql:mysql mysql-5.7.28-linux-glibc2.12-x86_64/*
[root@xkhadoop local]# ll
总用量 777932
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x. 9 mysql mysql 129 11月 24 15:47 mysql-5.7.28-linux-glibc2.12-x86_64
-rw-r--r--. 1 root root 760637440 11月 24 15:18 mysql-5.7.28-linux-glibc2.12-x86_64.tar
-rw-r--r--. 1 7161 31415 35959399 9月 27 16:58 mysql-test-5.7.28-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 11月 10 22:37 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
[root@xkhadoop local]# su mysql
4.创建软连接:
[root@xkhadoop mysql-5.7.28-linux-glibc2.12-x86_64]# ln -s /usr/local/mysql-5.7.28-linux-glibc2.12-x86_64 mysql
[root@xkhadoop mysql-5.7.28-linux-glibc2.12-x86_64]# ll
总用量 292
drwxr-xr-x. 2 mysql mysql 4096 11月 24 15:47 bin
drwxr-xr-x. 2 mysql mysql 55 11月 24 15:47 docs
drwxr-xr-x. 3 mysql mysql 4096 11月 24 15:47 include
drwxr-xr-x. 5 mysql mysql 230 11月 24 15:47 lib
-rw-r--r--. 1 mysql mysql 279547 9月 27 15:00 LICENSE
drwxr-xr-x. 4 mysql mysql 30 11月 24 15:47 man
lrwxrwxrwx. 1 root root 46 11月 24 15:57 mysql -> /usr/local/mysql-5.7.28-linux-glibc2.12-x86_64
-rw-r--r--. 1 mysql mysql 587 9月 27 15:00 README
drwxr-xr-x. 28 mysql mysql 4096 11月 24 15:47 share
drwxr-xr-x. 2 mysql mysql 90 11月 24 15:47 support-files
5.修改my.cnf文件,并修改my.cnf文件权限:
[root@xkhadoop mysql-5.7.28-linux-glibc2.12-x86_64]# cat /dev/null >/etc/my.cnf
[root@xkhadoop mysql-5.7.28-linux-glibc2.12-x86_64]# vim /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
[root@xkhadoop mysql-5.7.28-linux-glibc2.12-x86_64]# chown mysql:mysql /etc/my.cnf
[root@xkhadoop mysql-5.7.28-linux-glibc2.12-x86_64]# chmod 640 /etc/my.cnf
[root@xkhadoop mysql-5.7.28-linux-glibc2.12-x86_64]# ll /etc/my.cnf
-rw-r-----. 1 mysql mysql 2218 11月 24 16:04 /etc/my.cnf
6.初始化Mysql:
/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize
7.部署开机自启动:
[root@xkhadoop ~]# cd /usr/local/mysql
[root@xkhadoop mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql
#将服务文件拷贝到init.d下,并重命名为mysql
[root@xkhadoop mysql]# chmod +x /etc/rc.d/init.d/mysql
#赋予可执行权限
[root@xkhadoop mysql]# chkconfig --del mysql
#删除服务
[root@xkhadoop mysql]# chkconfig --add mysql
#添加服务
[root@xkhadoop mysql]# chkconfig --level 345 mysql on
[root@xkhadoop mysql]# su - mysql
[mysql@xkhadoop ~]$ bin/mysqld_safe &
8.登陆Mysql,改下密码
[mysql@xkhadoop data]$ mysql -uroot -p123456
set password=PASSWORD('123456');
9.如果还是无法在window机子上连接数据库,则执行这个命令:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.182.1' IDENTIFIED BY '123456' WITH GRANT OPTION
FLUSH PRIVILEGES;