Home >Database >Mysql Tutorial >How to install mysql5.7 on Linux

How to install mysql5.7 on Linux

WBOY
WBOYforward
2023-05-30 23:28:041038browse

MySQL is the most popular relational database management system. In terms of WEB applications, MySQL is the best RDBMS (Relational Database Management System: relational database) Management system) one of the application software.

How to install mysql5.7 on Linux

Specific steps to install mysql5.7 on Linux

Download address: https://dev.mysql.com/downloads/mysql/5.7.html#downloads

How to install mysql5.7 on Linux

Unzip

 tar -xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar

How to install mysql5.7 on Linux

##Move and rename again

 mv mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql

How to install mysql5.7 on Linux

Create mysql user groups and users and modify permissions

 groupadd mysql
 
 useradd -r -g mysql mysql

Create the data directory and grant permissions

 mkdir -p  /data/mysql              #创建目录
 
 chown mysql:mysql -R /data/mysql   #赋予权限

How to install mysql5.7 on Linux

Configure my.cnf

 vim /etc/my.cnf

The content is as follows

 [mysqld]
 
 bind-address=0.0.0.0
 
 port=3306
 
 user=mysql
 
 basedir=/usr/local/mysql
 
 datadir=/data/mysql
 
 socket=/tmp/mysql.sock
 
 log-error=/data/mysql/mysql.err
 
 pid-file=/data/mysql/mysql.pid
 
 #character config
 
 character_set_server=utf8mb4
 
 symbolic-links=0
 
 explicit_defaults_for_timestamp=true

How to install mysql5.7 on Linux

Initialize the database

Enter the bin directory of mysql

 cd /usr/local/mysql/bin/

Initialize

 ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize

View Password

 cat /data/mysql/mysql.err

How to install mysql5.7 on Linux

Start mysql and change the root password

First place mysql.server in /etc/init.d/

 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

in mysql starts! ! !

 service mysql start
 
 
 
 ps -ef|grep mysql

How to install mysql5.7 on Linux

This means that mysql has been installed successfully! !

Change the password below

First log in to mysql, the previous one is randomly generated.

 ./mysql -u root -p   #bin目录下

How to install mysql5.7 on Linux

Perform the following three steps and then log in again.

 SET PASSWORD = PASSWORD('123456');
 
 ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
 
 FLUSH PRIVILEGES;

How to install mysql5.7 on Linux

If you use remote connection at this time... you will find that you cannot connect.

How to install mysql5.7 on Linux

The following three commands are mainly executed here (log in to the database first)

 use mysql                                            #访问mysql库
 
 update user set host = '%' where user = 'root';      #使root能再任何host访问
 
 FLUSH PRIVILEGES;                                    #刷新

How to install mysql5.7 on Linux

How to install mysql5.7 on Linux

The above is the detailed content of How to install mysql5.7 on Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete