Home > Database > Mysql Tutorial > body text

What are the specific steps to install MySQL under Linux?

WBOY
Release: 2023-06-03 09:16:03
forward
565 people have browsed it

How to install MySQL under Linux? MySQL is a relational database management system. MySQL is one of the most popular relational database management systems. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System) application software.

Specific steps to install MySQL on Linux

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

What are the specific steps to install MySQL under Linux?

Unzip

 tar -xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar
Copy after login

What are the specific steps to install MySQL under Linux?

Move and rename it

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

What are the specific steps to install MySQL under Linux?

Create mysql user groups and users and modify permissions

 groupadd mysql
 
 useradd -r -g mysql mysql
Copy after login

Create the data directory and grant permissions

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

What are the specific steps to install MySQL under Linux?

Configure my.cnf

 vim /etc/my.cnf
Copy after login

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
Copy after login

What are the specific steps to install MySQL under Linux?

##Initialize the database

Enter the bin directory of mysql

 cd /usr/local/mysql/bin/
Copy after login

Initialization

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

View password

 cat /data/mysql/mysql.err
Copy after login

What are the specific steps to install MySQL under Linux?

Start mysql and change the root password

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

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

start up! ! !

 service mysql start
 
 
 ps -ef|grep mysql
Copy after login

What are the specific steps to install MySQL under 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目录下
Copy after login

What are the specific steps to install MySQL under Linux?

Perform the following three steps and then log in again.

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

What are the specific steps to install MySQL under Linux?

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

What are the specific steps to install MySQL under 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;                                    #刷新
Copy after login

What are the specific steps to install MySQL under Linux?

What are the specific steps to install MySQL under Linux?

ok! ! ! ! MySQL5.7 is installed... there are really many pitfalls... but if you follow this process, you should be able to install it smoothly. (Because I installed it twice...)

If you don’t want to go to the bin directory every time to use the mysql command, execute the following command

 ln -s  /usr/local/mysql/bin/mysql    /usr/bin
Copy after login

The above is the detailed content of What are the specific steps to install MySQL under Linux?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!