shell# yum install -y wget curl net-tools vim numactl perl-Time-HiRes git
shell# yum install -y epel-release
shell# yum install -y tmux htop iotop iftop bash-completion
shell# source /etc/profile.d/bash_completion.sh
shell# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.17-1.el8.x86_64.rpm-bundle.tar
shell# mkdir -p /mysql && tar -xvf mysql-8.0.17-1.el8.x86_64.rpm-bundle.tar -C /mysql
shell# yum localinstall -y /mysql/mysql-community-common-8.0.17-1.el8.x86_64.rpm /mysql/mysql-community-libs-8.0.17-1.el8.x86_64.rpm /mysql/mysql-community-server-8.0.17-1.el8.x86_64.rpm /mysql/mysql-community-client-8.0.17-1.el8.x86_64.rpm
shell# echo -e "\nlog_timestamps = SYSTEM" "\ncharacter_set_server=utf8" "\nlog_bin_trust_function_creators = on" "\nsql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES">> /etc/my.cnf
shell# systemctl start mysqld && systemctl enable mysqld
shell# firewall-cmd --zone=public --add-port=3306/tcp --permanent && firewall-cmd --reload
shell# grep 'temporary password' /var/log/mysqld.log
shell# mysql -u root -p
重置Mysql 密码以及权限
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Report@123';
shell# mysql -u root -pReport@123
mysql> GRANT ALL ON *.* TO 'root'@'%';
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'Report@123';
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Report@123';
#mysql查看当前时间
mysql> select curtime();
+-----------+
| curtime() |
+-----------+
| 15:47:51 |
+-----------+
1 row in set (0.00 sec)
#mysql查看当前时区
mysql> show variables like "%time_zone%";
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set (0.00 sec)
#修改当前时区,以系统时间为主,重启服务生效
shell: echo -e "\nlog_timestamps = SYSTEM" >> vim /etc/my.cnf
#或者修改当前时区,以区域时间为主,重启服务生效
shell: echo -e "\ndefault-time_zone = '+8:00'" >> vim /etc/my.cnf
#或者(修改mysql全局时区为北京时间,即所在的东8区)
mysql> set global time_zone = '+8:00';
#修改当前会话时区
mysql> set time_zone = '+8:00';
mysql> flush privileges;