Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install MySQL8.0 in CentOS7

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces you how to install MySQL8.0 in CentOS7, the content is very detailed, interested friends can refer to, hope to be helpful to you.

1. Uninstall

1. Check to see if mysql is installed

Rpm-qa | grep mysql

Delete

# rpm-e-- nodeps mysql-libs-5.1.71-1.el6.i686 or # for i in $(rpm-qa | grep mysql); do rpm-e $I-- nodeps;done

two。 Use the find /-name mysql command to find the relevant configuration files for the original mysql, such as:

/ etc/selinux/targeted/active/modules/100/mysql

/ usr/lib64/mysql

/ usr/share/mysql

Delete the above files in turn using the command rm-rf xxx

3. Use the rpm-qa | grep mariadb command to view

Uninstall using the rpm-e-- nodeps mariadb-libs-5.5.56-2.el7.x86_64 command

4. Rm / etc/my.cnf

II. Installation

1. download

Https://dev.mysql.com/downloads/mysql/

Select Operating System chooses Linux-Generic

Select OS Version chooses Linux-Generic (glibc 2.12) (x86, 64-bit)

Select Compressed TAR Archive 8.0.17 458.0M (mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz)

Click Download

two。 Upload files to / opt/

Cd / opt/

# rz

3. Decompression

# xz-d mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz

# tar-xvf mysql-8.0.17-linux-glibc2.12-x86_64.tar

4. Rename the package to mysql and move to the / usr/local/ directory

# mv mysql-8.0.17-linux-glibc2.12-x86_64 / usr/local/mysql

5. Create mysql groups and mysql users

Cat / etc/group | grep mysql

Cat / etc/passwd | grep mysql

# groupadd mysql

# useradd-r-g mysql mysql [# useradd-r-g mysql-s / bin/false mysql]

Change the password of the user mysql, such as 123456

# passwd mysql

6. Create a soft connection that can execute mysql directly on the command line

Ln-s / usr/local/mysql/bin/mysql / usr/bin

Or:

Add commands to environment variables

# vim / etc/profile

MYSQL_HOME=/usr/local/mysqlexport PATH=$MYSQL_HOME/bin:$PATH

# source / etc/profile

7. Create a data directory

# mkdir-p / usr/local/mysql/ {data,log,binlog,conf,tmp}

8. Assign permissions to relevant directories

# chmod-R 777 / usr/local/mysql

9. Grant permissions to the mysql directory to the mysql user and the mysql group

# chown-R mysql:mysql / usr/local/mysql

10. New profile

Vi / etc/my.cnf

[mysql] # set mysql client default character set default-character-set=utf8 [mysqld] skip-name-resolve# setting 3306 port port = 330 setting mysql installation directory basedir=/usr/local/mysql# setting mysql database data storage directory datadir=/usr/local/mysql/data# allows the maximum number of connections the character set used by the max_connections=200# server defaults to the 8-bit coded latin1 character set character-set- The default storage engine default-storage-engine=INNODB#lower_case_table_names=1max_allowed_packet=16M that server=utf8# will use when creating new tables

11. Initialize and remember randomly generated passwords

# cd / usr/local/mysql/bin/

#. / mysqld-initialize-console

Check the initialization process for error message log/mysqld.err

# cat mysqld.err | more

twelve。 Modify SELINUX=disabled

Vi / etc/selinux/config

# SELINUX=enforcing

SELINUX=disabled

13. Add boot boot mysql service and start mysql service

Add mysql service

Cp support-files/mysql.server / etc/init.d/mysql

Chmod 777 / etc/init.d/mysql

Start the mysql service

Service mysql start

# lsof-iPlus 3306

Turn off the mysql service

Service mysql stop

Restart the mysql service

Service mysql restart

14. Add Boot Startup Service

Check the list of self-starting items

Chkconfig-list mysql

Add

Chkconfig-add mysql

Set up boot boot

Chkconfig mysql on

15. Log in to the mysql database

# mysql-u root-p enter and use the previously randomly generated password

Reset password

Mysql > set PASSWORD = '123456'

Or

Mysql > alter user root@'localhost' identified by '123456 effective immediately

16. Enable remote access to mysql

Mysql > user mysql

Mysql > create user 'root'@'%' identified by' 123456'

Mysql > grant all privileges on *. * to 'root'@'%' with grant option

Mysql > ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY' 123456'

Mysql > flush privileges

Mysql > select host,user,plugin,authentication_string from user

Mysql > exit

17. Firewalls

View firewall status

Firewall-cmd-state

Turn on the firewall

Systemctl start firewalld.service

View the port on which to listen

Firewall-cmd-list-port

Add port 3306 snooping

Firewall-cmd-zone=public-add-port=3306/tcp-permanent

Refresh firewall settings

Firewall-cmd-reload

Or:

Port 3306 is released and this setting is added to the firewall rule

/ sbin/iptables-I INPUT-p tcp-- dport 3306-j ACCEPT

/ etc/rc.d/init.d/iptables save

On how to install MySQL8.0 in CentOS7 to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report