当前位置:网站首页>Centos7.9 install MySQL 5.7 and set startup

Centos7.9 install MySQL 5.7 and set startup

2022-06-27 06:37:00 fyihdg

Catalog

1、 download

 2、 install

 3、 Connect mysql

 4、 Set boot up


1、 download

Download address :

MySQL :: Download MySQL Community Serverhttps://dev.mysql.com/downloads/mysql/5.7.html

 

  Or download it here :

mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz-Java Document resources -CSDN download mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz Download more download resources on the official website 、 For learning materials, please visit CSDN Download channel .https://download.csdn.net/download/fyihdg/85605607

After downloading , Upload to server :

 2、 install

Check if it has been installed mysql

rpm -qa|grep mysql

  It's not installed

Check the system's own Mariadb

rpm -qa|grep mariadb

Unload the system Mariadb

establish mysql User groups and users

groupadd mysql
useradd -r -g mysql mysql

  Carry out orders :

tar -xvf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz  -C /opt

  Switch to /ope Catalog

Modify name

 mv mysql-5.7.38-linux-glibc2.12-x86_64/ mysql5.7

  Modify the permissions , User group

chown -R mysql:mysql /opt/mysql5.7
chmod -R 755 /opt/mysql5.7

  Get into :/opt/mysql5.7/bin, perform

./mysqld --initialize --user=mysql --datadir=/opt/mysql5.7/data --basedir=/opt/mysql5.7

New file :

vi /etc/my.cnf

Write the following :

[mysqld]
datadir=/opt/mysql5.7/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
# Table name case unknown , Sensitivity is 
lower_case_table_names=1

to grant authorization

chmod -R 775 /etc/my.cnf

Modify file :

 vi /opt/mysql5.7/support-files/mysql.server 

 

  Start the service :

/opt/mysql5.7/support-files/mysql.server start

 root      23261  21419  0 22:01 pts/0    00:00:00 grep --color=auto mysqld
[[email protected] support-files]# /opt/mysql5.7/support-files/mysql.server start
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Starting MySQL.my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Logging to '/opt/mysql5.7/data/node05.err'.
 ERROR! The server quit without updating PID file (/opt/mysql5.7/data/node05.pid).

Wrong report , There are reasons

1、 Data directory mysql The user does not have permission

2、/etc/my.cnf Configuration file configuration error ,[mysqld] Next set this line :datadir = /opt/mysql/data

3、 And that is /etc/ Format problem my.cnf

After successful startup :

Add soft connection , And restart mysql service

ln -s /opt/mysql5.7/support-files/mysql.server /etc/init.d/mysql

ln -s /opt/mysql5.7/bin/mysql /usr/bin/mysql
service mysql restart

 3、 Connect mysql

  User name is :root, The password is the password generated during the installation process

  modify root password :

set password for [email protected] = password('root');

Open remote connection


 

use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;

 

 

 4、 Set boot up

Execute the following command

// Copy the service file to init.d Next , And rename to mysql
cp /opt/mysql5.7/support-files/mysql.server /etc/init.d/mysqld
// Give executable permission 
chmod +x /etc/init.d/mysqld
// Add service 
chkconfig --add mysqld
// Show the list of services 
chkconfig --list

  If it doesn't work , Turn off firewall :

# Turn on the firewall 
systemctl start firewalld

# Turn off firewall 
systemctl stop firewalld

perhaps

// to open up 3306 Port command 
firewall-cmd --zone=public --add-port=3306/tcp --permanent
// Configuration takes effect immediately 
firewall-cmd --reload

thus , Installation successful

原网站

版权声明
本文为[fyihdg]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270625143279.html