1. Installation environment, Redhat Linux version centos6.8 (cat / etc / redhat-release)
Download the mysql installation package: https://dev.mysql.com/downloads/mysql/
2. Check whether there is a mysql installation package on this machine, if there is, you need to delete it
View: rpm -qa | grep mysql
delete: rpm -e --nodeps package name
–nodeps means to delete the rpm package without checking dependencies
3. Uninstall the mariadb that comes with the system, if any, you need to delete it
View: rpm -qa | grep mariadb
delete: rpm -e --nodeps package name
4. View all mysql directories and delete
View: find / -name mysql
delete: rm -rf / etc / mysql
5. After the preparation is completed, create a mysql folder with cd / usr / local / and transfer the mysql installation package that has just been downloaded to this folder
6. Unzip tar -xvf mysql-8.0.19-1.el6.x86_64.rpm-bundle.tar
7. Install common
rpm -ivh mysql-community-common-8.0.19-1.el6.x86_64.rpm --nodeps --force
8. Install libs
rpm -ivh mysql-community-libs-8.0.19-1.el6.x86_64.rpm --nodeps --force
9. Install client
rpm -ivh mysql-community-client-8.0.19-1.el6.x86_64.rpm --nodeps --force
10. Install the server
rpm -ivh mysql-community-server-8.0.19-1.el6.x86_64.rpm --nodeps --force
11. View the installation package of mysql through the rpm -qa | grep mysql command
12. After successful installation, perform some basic configuration on mysql
Modifying the configuration file my.cnf must be done before mysql initialization, otherwise it will cause the database to fail to start.
Official document lower_case_table_names can only be configured when initializing the server. Changing the lower_case_table_names setting after the server is initialized is prohibited. Case sensitive configuration)
vi /etc/my.cnf
[client]
port=3306
socket=/var/lib/mysql/mysql.sock
[mysqld]
port=3306
user=mysql
#默认加密方式
default-authentication-plugin=mysql_native_password
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#1表示大小写不敏感,0表示大小写敏感
lower_case_table_names=1
#限制server接受的数据包大小
max_allowed_packet=20M
#开启慢查询
slow_query_log=1
#慢查询最大时间5秒
long_query_time=5
#时区
default-time_zone='+8:00'
#关闭binlog日志
skip-log-bin
#sql语法校验
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
13.mysql initialization
mysqld --initialize
14. Change the owner and group of the data file directory
chown -R mysql:mysql /var/lib/mysql
-R all files in the specified directory and its subdirectories
15. Start mysql
service mysqld start
16. View the password of the database
cat /var/log/mysqld.log | grep password
17. Log in to mysql
mysql -uroot -p
Enter the password just found
18. Change the password of the root user to root, (localhost means local user)
alter user 'root'@'localhost' identified with mysql_native_password by 'root'
with mysql_native_password indicates that the encryption method is mysql_native_password, version 8.0 is different from the encryption method of MySQL5 version. If it is not set to mysql_native_password, it will cause the visualization tool (navicat) to fail to link
19. Quit mysql
exit
20. Log in again with a new password
mysql -uroot -proot
21. Create a new user
create user 'jack'@'%' identified by 'jack123'
Create users and grant permissions can refer to https://blog.csdn.net/qq_40977118/article/details/104380177
22. Turn off the firewall
service iptables stop