Centos7.4-MySQL5.7.22解压安装配置

安装环境简介:
系统版本:cantos7.4

jdk版本:1.8

mysql版本:5.7.22

1.下载
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

2.解压
[root@test06 ~]# cd /tools/
[root@test06 tools]# tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

3.创建目录
[root@test06 tools]# cd /usr/local/
[root@test06 local]# ll
total 0
drwxr-xr-x. 2 root root   6 Nov  5  2016 bin
drwxr-xr-x. 2 root root   6 Nov  5  2016 etc
drwxr-xr-x. 2 root root   6 Nov  5  2016 games
drwxr-xr-x. 2 root root   6 Nov  5  2016 include
drwxr-xr-x. 2 root root   6 Nov  5  2016 lib
drwxr-xr-x. 2 root root   6 Nov  5  2016 lib64
drwxr-xr-x. 2 root root   6 Nov  5  2016 libexec
drwxr-xr-x  9 root root 129 Apr  1 04:24 mysql-5.7.22-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root   6 Nov  5  2016 sbin
drwxr-xr-x. 5 root root  49 Mar 22 10:52 share
drwxr-xr-x. 2 root root   6 Nov  5  2016 src
[root@test06 local]# mv mysql-5.7.22-linux-glibc2.12-x86_64/ mysql-5.7.22
[root@test06 local]# cd mysql-5.7.22/
[root@test06 mysql-5.7.22]# mkdir data

4.创建用户和组
groupadd mysql
useradd -r -g mysql mysql

5、授权:
[root@test06 mysql-5.7.22]# chown -R mysql:mysql /usr/local/mysql-5.7.22/

6.安装
[root@test06 mysql-5.7.22]# cd bin/
[root@test06 bin]# /usr/local/mysql-5.7.22/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql-5.7.22 --datadir=/usr/local/mysql-5.7.22/data
2022-04-01T08:29:37.226895Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-04-01T08:29:39.561990Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-04-01T08:29:39.911327Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-04-01T08:29:40.010940Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: df87dce6-b195-11ec-ad4e-08002734c59b.
2022-04-01T08:29:40.033011Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-04-01T08:29:40.035430Z 1 [Note] A temporary password is generated for root@localhost: (DhqClaWS24q
[root@test06 bin]#

记住临时密码 :(DhqClaWS24q

7.添加配置文件
[root@test06 bin]# cd ..
[root@test06 mysql-5.7.22]# vim my.cnf
[client]
port = 3706
socket = /tmp/mysql.sock
[mysqld]
port = 3706
socket = /tmp/mysql.sock
character_set_server=utf8
basedir = /usr/local/mysql-5.7.22
datadir = /usr/local/mysql-5.7.22/data
pid-file = /usr/local/mysql-5.7.22/mysql.pid
tmpdir =  /usr/local/mysql-5.7.22/tmp_dir_mysql
user= mysql
bind-address = 0.0.0.0
server-id = 1
default_password_lifetime=0
skip-name-resolve
general_log = 1
general_log_file = /usr/local/mysql-5.7.22/mysql.log
back_log = 600
max_connections = 3000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 2000
max_allowed_packet = 1024M
binlog_cache_size = 2M
max_heap_table_size = 6000M
tmp_table_size = 200M
read_buffer_size = 8M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 100
query_cache_size = 4M
query_cache_limit = 1M
key_buffer_size = 16M
ft_min_word_len = 4
transaction_isolation = READ-COMMITTED
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
log_error = /usr/local/mysql-5.7.22/mysql-error.log
slow_query_log = 1
long_query_time = 50
slow_query_log_file = /usr/local/mysql-5.7.22/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
lower_case_table_names = 1
skip-external-locking
default-storage-engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 3000
innodb_buffer_pool_size = 6144M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
sync_binlog = 0
innodb_flush_log_at_trx_commit = 0
innodb_log_buffer_size = 8M
innodb_log_file_size = 1500M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_autoinc_lock_mode = 2
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
log_bin_trust_function_creators=true
sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_IN_DATE,NO_ZERO_DATE
[mysqldump]
quick
max_allowed_packet = 64M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

8.启动:
[root@test06 mysql-5.7.22]# mkdir tmp_dir_mysql
[root@test06 mysql-5.7.22]# touch mysql-error.log
[root@test06 mysql-5.7.22]# chown -R mysql:mysql /usr/local/mysql-5.7.22/
[root@test06 mysql-5.7.22]# /usr/local/mysql-5.7.22/bin/mysqld_safe --defaults-file=/usr/local/mysql-5.7.22/my.cnf --user=mysql &
[1] 19749
[root@test06 mysql-5.7.22]# 2022-04-01T08:48:09.995476Z mysqld_safe Logging to '/usr/local/mysql-5.7.22/mysql-error.log'.
2022-04-01T08:48:10.055358Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.7.22/data
^C
[root@test06 mysql-5.7.22]# ps -ef|grep mysql
root     19749 17478  0 04:48 pts/1    00:00:00 /bin/sh /usr/local/mysql-5.7.22/bin/mysqld_safe --defaults-file=/usr/local/mysql-5.7.22/my.cnf --user=mysql
mysql    20647 19749 33 04:48 pts/1    00:00:29 /usr/local/mysql-5.7.22/bin/mysqld --defaults-file=/usr/local/mysql-5.7.22/my.cnf --basedir=/usr/local/mysql-5.7.22 --datadir=/usr/local/mysql-5.7.22/data --plugin-dir=/usr/local/mysql-5.7.22/lib/plugin --user=mysql --log-error=/usr/local/mysql-5.7.22/mysql-error.log --open-files-limit=65535 --pid-file=/usr/local/mysql-5.7.22/mysql.pid --socket=/usr/local/mysql-5.7.22/mysql.sock --port=3706
root     20739 17478  0 04:49 pts/1    00:00:00 grep --color=auto mysql
[root@test06 mysql-5.7.22]#

9.客户端连接
[root@test06 mysql-5.7.22]# /usr/local/mysql-5.7.22/bin/mysql -uroot -p
Enter password: (DhqClaWS24q
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22-log
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

10.设置密码
mysql> set password for 'root'@localhost=password('mysql@2022');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql>

11.开启root用户远程登录
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select User,authentication_string,Host from user;
+---------------+-------------------------------------------+-----------+
| User          | authentication_string                     | Host      |
+---------------+-------------------------------------------+-----------+
| root          | *CEB300FC2A85CFA86D87B733669ABF3E588A2824 | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
| mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
+---------------+-------------------------------------------+-----------+
3 rows in set (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql@2022';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> select User,authentication_string,Host from user;
+---------------+-------------------------------------------+-----------+
| User          | authentication_string                     | Host      |
+---------------+-------------------------------------------+-----------+
| root          | *CEB300FC2A85CFA86D87B733669ABF3E588A2824 | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
| mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
| root          | *CEB300FC2A85CFA86D87B733669ABF3E588A2824 | %         |
+---------------+-------------------------------------------+-----------+
4 rows in set (0.00 sec)

mysql> quit;
Bye
[root@test06 mysql-5.7.22]$

远程连接:

IP:192.168.189.6  端口:3706

账户:root 密码:mysql@2022

posted @ 2022-04-01 17:13  深海蓝精灵  阅读(133)  评论(0编辑  收藏  举报