当前位置:网站首页>10 minutes to master the installation steps of MySQL
10 minutes to master the installation steps of MySQL
2022-06-27 16:29:00 【Yufanghuashou】
mysql As a database commonly used in daily development , It's very important for every programmer , Come with me today mysql Your installation journey .
One 、 install
1、 How to install the package
1.1、 Get installation package
Yes mysql For people who have been in contact , We all know mysql It is divided into commercial version and community version , Because it's just for development 、 The use of learning , Select the community version here to install . First open the official website .
https://www.mysql.com/

mysql Download from the official website
Go to the download page , Slide to the bottom to see the download link of the community version , Here's the picture ,

mysql Download address
Jump to the download page of the Community Edition

mysql The download page
You can see that there are many ways to install , Here, first select the installation package of binary files , Go to the corresponding page , Select the required version to download , The environment I want to install here is centos7, So the following version is selected here ,

When the download is complete , Use rz The command is uploaded to linux On the machine ,rz The order is linux Command below , If you don't have this command, you can install Baidu by yourself .

1.2、 Use the installation package to install ( Failed to install )
In the above steps, the installation package has been successfully uploaded to linux On the machine , Pictured above , The next step is to decompress , Use the following command ,
tar -xvf mysql-8.0.26-1.el8.x86_64.rpm-bundle.tar After decompression , You can see these files

mysql The extracted file
Just install it , Here is rpm package , So use rpm Command to install

mysql install
Show the following ,

mysql Error during installation
Indicates a missing dependency , For example, lack of GLIBC_2.28、OPENSSL_1_1_0 etc. , I haven't successfully installed it here , So it doesn't continue here , A friend who knows something can give me a suggestion . Next, install in another way .
2、yum The way
2.1、 Get the installation file
stay mysql Your download page is mysql Of yum file ,

download mysql Of yum file
Download this file to your local ,

Download local yum file
Upload the file to linux On the machine , As mentioned earlier, you can use rz command , I have passed it here ,

Upload to linux Of yum file
Let's install
2.2、 install
2.2.1、 add to mysql Of rpm To yum Source
Because of the yum Installation method of , So put the above yum Add files to yum In the source ,
yum localinstall mysql80-community-release-el7-3.noarch.rpm Check yum In source mysql
yum repolist all | grep mysql 
You can see that the newly added status is enabled , Pictured above , in addition , If there are other versions whose status is enabled , Be sure to shut it down , Use the following command
yum-config-manager --disable MySQL Cluster 7.5 Community2.2.2、 Delete previous version
If you've installed it before mysql, You can use the following command to view
yum list installed | grep mysqlI've installed... Here , So there are the following dependencies

You can use the following command to delete
yum -y remove mysql-community-client.x86_64
2.2.3、 install
Use the following installation command to install ,
yum install mysql-community-serverHere's the picture

mysql setup script
Just install it .
After installation, check whether the installation is successful .

The figure above shows that the installation has been successful .
Two 、 To configure
Just installed mysql Can only be accessed locally , Lack of remote access , So here we need to configure , Because of the use of yum Install by default , that mysql Where was it installed? That
2.1、mysql Installation position of
Use the following command
which mysqldThe results are as follows

After installation mysql The location of
You can see that it is installed in /usr/sbin Under the table of contents ,
that mysql Where is your configuration file ,
/usr/sbin/mysqld --verbose --help |grep -A 1 'Default options' Here's the picture ,

As can be seen from the above, first read /etc/my.cnf, And then there was etc/mysql/my.cn And then there was /usr/etc/my.cnf Continue reading in this order , That is to say, only one directory exists in the above paths my.cnf that will do . Let's look at /etc/ Whether there is

my.cnf The location of
The file exists , Edit the file
The document is as follows ,

my.inf The contents of the document
You can see mysql Data directory for 、pid Other configuration . remember log-error=/var/log/mysqld.log This configuration . All right, let's start
2.2、 start-up mysql
Use the following command to start mysql
service mysqld start
mysql Start state of
You can see that it has been started successfully . Now log in
2.3、 Log in locally
Now the service has started ,mysql It comes with a local client , You can use the client mode to start , So what's our account and password? That , Don't worry , Above we remember log-error=/var/log/mysqld.log This is also a configuration , This is a mysql Start log , Look at this file

mysql Your default account number
Find the key sentence from the above , That is to say mysql When starting, it will give root A temporary password , I am here 0Q*_k1F.KFo9, Use this password to log in ,
mysql -hlocalhost -uroot -p
Log in with the default account mysql
You can see that you have successfully logged in , Just mentioned that root Your password is temporary , Then you need to change the password now .
2.4、 modify root The temporary password for
You have just logged in successfully , But because you use a temporary password , So I can't do anything , You must change the temporary password ,

mysql> alter user [email protected] identified by '123!QAZ';Change your password here . That's it root Password modification . Use exit After the command exits , Just log in with a new password .
2.5、 Add remote login account
mysql> create user 'root'@'%' identified by 'root';// Refresh the permissions mysql> flush privileges;Added root Your remote login account ;

In this way, you can use root Remote login .
2.6、 Use navicat Remote login
Use navicat Connect mysql, here mysql The version is 8, The following error occurred while connecting

Log in locally using the command line , Execute the following command
mysql> use mysql;mysql> alter user 'root'@'%' identified with mysql_native_password by '123!QAZ';mysql> flush privileges;Then log in as follows ,

2.7、 to grant authorization
You can see from the above picture that root The permission of the account is obviously not the maximum , It needs to be authorized ,
mysql> grant all privileges on *.* to 'root'@'%' WITH GRANT OPTION;mysql> flush privileges;
3、 ... and 、 summary
This article records mysql Installation steps of , And threw out some problems and solutions , The problems left in this paper , I hope you can come up with a solution , Thank you for your .
边栏推荐
- Event listening mechanism
- Markdown syntax
- 继手机之后 报道称三星也削减了电视等家电产品线的产量
- Alibaba cloud liupeizi: Inspiration from cloud games - innovation on the end
- Array represents a collection of several intervals. Please merge all overlapping intervals and return a non overlapping interval array. The array must exactly cover all the intervals in the input. 【Le
- 阿里云刘珅孜:云游戏带来的启发——端上创新
- Logstash excludes specific files or folders from collecting report log data
- Construction and management practice of ByteDance buried point data flow
- What is the level 3 password complexity of ISO? How often is it replaced?
- What is the open source compatibility of the current version of polardb-x? mysql8?
猜你喜欢
![[pyGame games] this](/img/3c/e573106ec91441a554cba18d5b2253.png)
[pyGame games] this "eat everything" game is really wonderful? Eat them all? (with source code for free)

Raspberry pie preliminary use

带你认识图数据库性能和场景测试利器LDBC SNB

鴻蒙發力!HDD杭州站·線下沙龍邀您共建生態

事务的四大特性

Redis系列2:数据持久化提高可用性

Yyds dry inventory solution sword finger offer: a path with a certain value in the binary tree (3)

一个机器人位于一个 m x n 网格的左上角 。机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角。问总共有多少条不同的路径?【LeetCodeHot100】

字节跳动埋点数据流建设与治理实践

树莓派初步使用
随机推荐
C语言教师工作量管理系统
LeetCode每日一练(杨辉三角)
The array of C language is a parameter to pass a pointer
QT5 之信号与槽机制(演示控件自带的信号与槽函数关联)
The role of the symbol @ in MySQL
P.A.R.A 方法在思源的简易应用(亲测好用)
If you want to use DMS to handle database permissions, can you only use Alibaba cloud ram accounts (Alibaba cloud RDS)
等保三级密码复杂度是多少?多久更换一次?
Leetcode daily practice (Yanghui triangle)
继手机之后 报道称三星也削减了电视等家电产品线的产量
#yyds干货盘点# 解决剑指offer:二叉树中和为某一值的路径(三)
Regular matching starts with what, ends with what, starts with what, and ends with what
一场分销裂变活动,不止是发发朋友圈这么简单!
Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
阿里云刘珅孜:云游戏带来的启发——端上创新
Yyds dry inventory brief chrome V8 engine garbage collection
Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing
Basic configuration and usage of Jupiter notebook
localDateTime类型的时间(2019-11-19T15:16:17) 用oracle的时间范围查询
Scrapy framework (I): basic use