当前位置:网站首页>Detailed steps for installing MySQL 8.0 under Linux
Detailed steps for installing MySQL 8.0 under Linux
2022-07-29 03:04:00 【Strange elephant】
Linux Lower installation MySQL8.0 Step by step
Set up a cloud server , The first thing to do is to install the database , stay Windows It goes without saying that , Fool operation , stay Linux At least record the installation on .
I'm using XShell7 ssh Connection tool access Linux, The usage and commands of other tools are the same , The interface is as follows :
What I use here is not root User logged in , So switch to root user , command :su
First step : Download installation configuration
Switch to /usr/local/
cd /usr/local/
establish mysql Folder
mkdir mysql
Switch to mysql Under the folder
cd mysql
download mysql8.0 Installation package
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
Wait for the download to succeed

decompression mysql8.0 Installation package
tar xvJf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz

Rename the extracted folder , This is changed into mysql-8.0
mv mysql-8.0.20-linux-glibc2.12-x86_64 mysql-8.0
. /use/local/mysql-8.0 Create under folder data Folder Storage file
mkdir data
Create user groups and users and passwords respectively ( If the prompt already exists, it indicates that it has been created before )
groupadd mysql
useradd -g mysql mysql
Authorize the newly created user
chown -R mysql.mysql /usr/local/mysql/mysql-8.0 chmod 750 /usr/local/mysql/mysql-8.0/data -RConfiguration environment , edit /etc/profile file
Be careful : There's a pit here , After configuring the environment variables , You need to perform sourc /etc/profile command , Make profile effective
vim /etc/profile
#--------------------------
# Click on the i key , Enter input mode , Add a line at the end of the configuration file :
#--------------------------
export PATH=$PATH:/usr/local/mysql/mysql-8.0/bin:/usr/local/mysql/mysql-8.0/lib
# When I'm done , Press Esc Key to exit input mode , Enter command mode , Input :wq, Save and exit
# And then input cat /etc/profile See if it was saved successfully , The effect is as follows :↓↓↓↓↓↓

11. edit my.cnf file
vi /etc/my.cnf
[mysql]
default-character-set=utf8mb4
[client]
#port=3306
socket=/var/lib/mysql/mysql.sock
[mysqld]
#port=3306
#server-id=3306
user=mysql
general_log = 1
general_log_file= /var/log/mysql/mysql.log
socket=/var/lib/mysql/mysql.sock
basedir=/usr/local/mysql/mysql-8.0
datadir=/usr/local/mysql/mysql-8.0/data
log-bin=/usr/local/mysql/mysql-8.0/data/mysql-bin
innodb_data_home_dir=/usr/local/mysql/mysql-8.0/data
innodb_log_group_home_dir=/usr/local/mysql/mysql-8.0/data/
character-set-server=utf8mb4
lower_case_table_names=1
autocommit=1
default_authentication_plugin=mysql_native_password
symbolic-links=0
# Disabling symbolic-links is recommended to prevent assorted security risks
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/usr/local/mysql/mysql-8.0/data/mysql.log
pid-file=/usr/local/mysql/mysql-8.0/data/mysql.pid
#
# include all files from the config directory
- Switch to /usr/local/mysql/mysql-8.0/bin Under the table of contents
cd bin
- Initialize basic information , Get the initial password of the database ( stay /usr/local/mysql/mysql-8.0/bin Execute under directory )
./mysqld --user=mysql --basedir=/usr/local/mysql/mysql-8.0 --datadir=/usr/local/mysql//mysql-8.0/data/ --initialize
# Once the initialization is complete , Copy the last initial password , If you save it, you need ( This step seems useless )
#igTn=3j-
- Copy mysql.server file , stay /usr/local/mysql/mysql-8.0 Execute under directory
cp -a ./support-files/mysql.server /etc/init.d/mysql
cp -a ./support-files/mysql.server /etc/init.d/mysqld
- To give permission
chown 777 /etc/my.cnf
chmod +x /etc/init.d/mysql
chmod +x /etc/init.d/mysqld
- Check the /var/lib/mysql Whether there is , Otherwise, create
mkdir /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql/
- Start database , Yes SUCCESS Word description MySQL installation is complete
service mysql start
# appear SUCCESS Indicating successful startup , The renderings are as follows :

ps:
If startup fails , You can check it first data Inside mysql.log, If there's a hint 3306 Words like this , The first thought should be that the port is occupied ,
Use lsof -i: Port number , Check which one is PID( Process number ) The port is occupied , And then use kill PID( Process number ) Kill the process , Re execution service mysql start
The second step : Change Password , And set up remote connection ( In order to connect this under other machines mysql)
I wasted a lot of time at the beginning of this step . If you log in with the previous initial password , The following errors may occur :
At this stage , Studied for a long time , Record the process :
- stay vim /etc/my.cnf In file , stay [mysqld] Add a sentence to the paragraph :skip-grant-tables -- Skip password verification
- Then save to exit , restart MySQL service
- Then input mysql -uroot -p Hit enter twice , Get into mysql
- USE mysql ; -- Access to database
- stay mysql8.0 in , This update syntax cannot be used UPDATE user SET Password = password ( ‘new-password’ ) WHERE User = ‘root’ ; Use this :ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘ New password ’;
- Finally, just follow the steps below .
modify the database root Password of account , And set up remote access ( because root The default is not remotely accessible )
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘ New password ’;
perform flush privileges; Make the password effective
flush privileges;# Refresh the permissions
Select database
use mysql;
Then modify the remote connection and take effect
mysql> create user ‘root’@‘%’ identified by ‘password’;
Query OK, 0 rows affected (0.03 sec)mysql> grant all privileges on . to ‘root’@‘%’ with grant option;
Query OK, 0 rows affected (0.01 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)Execute the submit command , Get it done !
flush privileges;# Refresh the permissions
边栏推荐
猜你喜欢

Look at robot education and lead the mainstream of quality education

C语言程序设计 | 交换二进制数奇偶位(宏实现)

融云实时社区解决方案

Feedback function of conference OA

Idea replaces the contents of all files
![[opencv] use OpenCV to call mobile camera](/img/66/6207bafbc9696e43da7a60a386a238.jpg)
[opencv] use OpenCV to call mobile camera

Mongodb index (3)

R language error: compilation failed for package '****‘

navicat新建数据库

解析Steam教育中的项目式学习创造力
随机推荐
Pgzero飞机大战
C traps and defects Chapter 3 semantic "traps" 3.4 avoid "couple method"
MYSQL入门与进阶(十一)
Day 8 notes
What is SOA (Service Oriented Architecture)?
Interpreting AI robots' pet raising and leading fashion trends
会议OA项目之我的审批功能
算法---粉刷房子(Kotlin)
Confusion matrix learning notes
MYSQL入门与进阶(十三)
数字图像处理 第10章——图像分割
CentOS install mysql8
Analysis of concepts and terms in data warehouse
Shell编程规范与变量
Multi table (Association) query of SQL query data
C陷阱和缺陷 第3章 语义“陷阱” 3.2 非数组的指针
Day 5 experiment
C语言基础知识点汇总
Mongodb index (3)
C语言程序设计 | 交换二进制数奇偶位(宏实现)