1. Configure JDK
1.1 Download JDK
Install jdk8 this time, download address Java SE Development Kit 8 - Downloads
1.2 Put the JDK on the server, and personally put it in the /usr/local/soft directory, choose according to your personal situation
1.3 Create a new directory
mkdir /usr/local/java
1.4 Unzip the jdk tar package to /usr/local/java/
cd /usr/soft
tar -xvf jdk-8u301-linux-x64.tar.gz -C /usr/local/java/
1.5 Update /etc/profile, add content at the end
export JAVA_HOME=/usr/local/java/jdk1.8.0_301
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
1.6 Refresh environment variables
source /etc/profile
1.7 Verify JDK
java -version
2. Install mysql8 and configure case-insensitive lower_case_table_names=1
If you have not installed mysql, skip steps 2.1, 2.2, 2.3, 2.4, 2.5, 2.6
2.1 Check to uninstall mysql
rpm -qa|grep -i mysql
2.2 Stop mysql
systemctl stop mysqld.service
2.3 Uninstall files
rpm -e –nodeps 包名
2.4 Find mysql related files and directories
find / -name mysql
2.5 Delete the corresponding mysql file and directory
rm -rf 文件或目录名称
2.6 Manually delete /etc/my.cnf
rm -rf /etc/my.cnf
2.7 download mysql8
Download link: MySQL :: MySQL Downloads
Download to /usr/soft
The address is posted: https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz
2.8 Decompress the tar package
tar -xvf /usr/soft/mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz
2.9 Move to /usr/local/mysql
mv /usr/soft/mysql-8.0.26-linux-glibc2.12-x86_64 /usr/local/mysql
2.10 Create mysql groups and users
groupadd mysql
useradd -r -g mysql mysql
2.11 Create mysql data directory / return to the root directory
cd / && mkdir -p /data/mysql_data/
2.12 Authorization
chown mysql:mysql -R /data/mysql_data
chmod 750 /data/mysql_data/ -R
2.13 To avoid always having to type the pathname of the client program when using MySQL, you can add /usr/local/mysql/bin
the directory PATH
to the variable:
export PATH=$PATH:/usr/local/mysql/bin
2.14 my.cnf configuration parameters
Create the my.cnf configuration file for initializing the mysql database
The order in which configuration files are read by default:
Default options are read from the following files in the given order:
1. /etc/my.cnf 2./etc/mysql/my.cnf 3./usr/local/mysql/etc/ my.cnf 4.~/.my.cnf
vim /etc/my.cnf and press i to enter the edit mode, copy the following content into it
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
server-id = 3306
user = mysql
socket = /tmp/mysql.sock
# 设置mysql的安装目录
basedir = /usr/local/mysql8
# 设置mysql数据库的数据的存放目录
datadir = /data/mysql_data/mysql
log-bin = /data/mysql_data/mysql/mysql_bin
innodb_data_home_dir =/data/mysql_data/mysql
innodb_log_group_home_dir =/data/mysql_data/mysql
#设置mysql数据库的日志及进程数据的存放目录
log-error =/data/mysql_data/mysql/mysql.log
pid-file =/data/mysql_data/mysql/mysql.pid
# 服务端使用的字符集默认为8比特编码
character-set-server=utf8mb4
lower_case_table_names=1
autocommit=1
##################以上要修改的########################
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 1024
sort_buffer_size = 4M
net_buffer_length = 8K
read_buffer_size = 4M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 64M
thread_cache_size = 128
#query_cache_size = 128M
tmp_table_size = 128M
explicit_defaults_for_timestamp = true
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
binlog_format=mixed
binlog_expire_logs_seconds =864000
# 创建新表时将使用的默认存储引擎
default_storage_engine = InnoDB
innodb_data_file_path = ibdata1:10M:autoextend
innodb_buffer_pool_size = 1024M
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
transaction-isolation=READ-COMMITTED
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 4M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
After editing, press esc and then hold down shift+: input wq means save and exit: wq!
2.15 Initialize mysql
cd /usr/local/mysql/bin/
#一行
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql_data/mysql --user=mysql --initialize
2.16 Create MySQL service
cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql
2.17 View mysql startup status
service mysql status
2.16 Start mysql and change the root password
service mysql start
2.17 Login to mysql
mysql -u root -p
The password is a random password generated during initialization, if you forget it, please check /data/mysql_data/mysql/mysql.log
2.18 Change password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
2.19 Execute to make the password valid
flush privileges;
2.20 Select mysql database
use mysql;
2.21 Modify remote connection
update user set host='%' where user='root';
flush privileges;
3. Firewall
3.1 View firewall status
firewall-cmd --state
3.2 Open the firewall
systemctl start firewalld
3.3 Turn off the firewall
systemctl stop firewalld
3.4 Add ports 3306, 8082, 8083
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --add-port=8082/tcp --permanent
firewall-cmd --zone=public --add-port=8083/tcp --permanent
3.5 Restart the firewall. After changing the firewall, it must be restarted to take effect
firewall-cmd --reload
3.6 View all open ports
firewall-cmd --list-ports