当前位置:网站首页>Play with Linux and easily install and configure MySQL
Play with Linux and easily install and configure MySQL
2022-06-26 17:00:00 【Small hook】
This article mainly explains in Linux Installation on 、 Configure and use MySQL, Used in this article Linux System is CentOS7.6 edition
lately Yige Purchased a virtual host , however Yige Very poor , So I only bought a simple virtual host , Except for one CentOS Beyond the system , There is really nothing left . but Yige It has to be used MySQL, So it can only be in this CentOS Install manually in MySQL 了 , therefore Yige Just install yourself MySQL The process is recorded , For your reference .
One 、 be based on Linux Systematic MySQL install
This article mainly explains manual installation MySQL, There is no use of foolishness Docker, That's too simple ......
1.1 Use wget Instruction Download MySQL Of rpm package
install MySQL Before , Be sure to have MySQL Installation package , here Yige Use wget To download .
stay Linux The system creates and enters the specified directory , The following is a /usr/local Catalog , Use pwd Command to view the path of the current directory , And then through wget Instruction now mysql Of rpm package , Download here mysql Version is 5.7.
[[email protected] local]# pwd/usr/local[[email protected] local]# wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm1.2 adopt rpm install MySQL
MySQL After downloading , utilize rpm Installation .
adopt rpm Instructions to install downloaded rpm package
[[email protected] local]# rpm -ivh mysql57-community-release-el7-10.noarch.rpm1.3 adopt yum install mysql service
Next we have to open mysql service .
MySQL It runs in the system as a service , install rpm The package is then passed yum Command installation MySQL service
[[email protected] local]# yum -y install mysql-community-serverinstall mysql In the process of service , You may encounter the following errors :

If the above installation error occurs , Indicates... During installation GPG Verification failed , We can do it in yum Add after the command
--nogpgcheck Options Re perform the installation :
[[email protected] local]# yum -y install mysql-community-server --nogpgcheckTwo 、MySQL Service management
MySQL After the software is installed , We need to be right about MySQL Make the necessary configuration , Here's the configuration mysql Common commands for service .
2.1 take MySQL The service is added and started
add to mysql After startup ,MySQL The service will start with the system startup .
[[email protected] local]# systemctl enable mysqld2.2 start-up MySQL service
stay CentOS7 Can be used in systemctl Service management , If you use it Linux The system version does not support systemctl, You can also use service mysqld start To start up MySQL service .
[[email protected] local]# systemctl start mysqld [[email protected] local]# lsof -i:3306COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEmysqld 8430 mysql 17u IPv6 70095 0t0 TCP *:mysql (LISTEN)2.3 stop it MySQL service
[[email protected] local]# systemctl stop mysqldOr use :
[[email protected] local]# service mysqld stop3、 ... and 、MySQL Basic use
Next we can use MySQL 了 .
3.1 lookup MySQL Initial password
MySQL After the service starts , We can go through mysql Command start MySQL Client connection MySQL database , Connection needs root Account password , In the installation MySQL Is generated by default root The initial password of the account is recorded in /var/log/mysqld.log In file , adopt cat The command can query the first-time password , The execution instructions are as follows :
[[email protected] local]# cat /var/log/mysqld.log | grep passwordAs shown in the following figure, the initial password is displayed in the empty color box of the execution result

3.2 Log in with the initial password MySQL
perform mysql Instructions ,-u After the option root Represents the user name ,-p Enter without adding parameters after the option , Then enter the initial password ( There is no feedback in the input box when entering the password , Enter directly after the input ), appear mysql> Execution tips , Indicates successful login .

3.3 modify MySQL Initial password
The initial password is only used for login , After logging in, you must change the initial password to perform database operations ; because MySQL With password security verification , Therefore, you can set the password verification policy to LOW, Then set the password , as follows :
In particular : The password is set in mysql Client input sql command
# Set the password checking mechanism to LOWmysql> set global validate_password_policy=LOW;# Change Password mysql> set password=password('admin123');3.4 to grant authorization root Users are allowed to log in remotely
After the password is changed , perform exit Instructions , sign out mysql client , Then login again with the modified password

After login ,root The user does not support remote connection by default , If you want to use a remote client (Navicat、SQLYog etc. )root Account connection MySQL Database authorization , Can be specified during authorization root Password for remote connection of account ( The following command password is admin123)
mysql> GRANT ALL PRIVILEGES on *.* to 'root'@'%' IDENTIFIED by 'admin123' WITH GRANT OPTION;mysql> flush PRIVILEGES;After the above two instructions are completed , You can try it navicat Connect MySQL Database !
PS: If the ECS is used Linux System , Also note the security group configuration release 3306 Port yo ~
Now you know how to CentOS Install, configure, and use MySQL Did you? ? If there is any doubt , You can leave a message to Yige in the comment area , Let me solve it for you .
边栏推荐
- Programmer's essential toolkit, please collect!
- proxy
- Scala Foundation (2): variables et types de données
- Call the random function to generate 20 different integers and put them in the index group of institute a
- Leetcode 1169. 查询无效交易(如果数据量不大,这种题还是得暴力枚举解决)
- day10每日3题(3):数组中的字符串匹配
- y=1/100*100+1/200*200+1/300*300+.....+ 1/m*m
- r329(MAIX-II-A(M2A)资料汇总
- Sandboxed container: container or virtual machine
- What is the preferential account opening policy of securities companies now? Is it safe to open an account online now?
猜你喜欢

Stm32h7b0 replaces the h750 program, causing the MCU to hang up and unable to burn the program

Web3 decentralized storage ecological landscape

Platform management background and merchant menu resource management: access control design of platform management background
![[suggested collection] 11 online communities suitable for programmers](/img/6b/d5c68e93384fd314d0cb27d9df1cb9.jpg)
[suggested collection] 11 online communities suitable for programmers

Structure the graduation project of actual combat camp

Make up the weakness - Open Source im project openim about initialization / login / friend interface document introduction

数字藏品与NFT到底有何区别

Interpretation of cloud native microservice technology trend

Cloud platform monitoring system based on stm32+ Huawei cloud IOT design

Byte interview: two array interview questions, please accept
随机推荐
The latest masterpiece of Alibaba, which took 182 days to produce 1015 pages of distributed full stack manual, is so delicious
Set up your own website (16)
Interpretation of cloud native microservice technology trend
y=1/100*100+1/200*200+1/300*300+.....+ 1/m*m
数字藏品与NFT到底有何区别
When I was in the library, I thought of the yuan sharing mode
对NFT市场前景的7个看法
Teach you to learn dapr - 8 binding
C语言 头哥习题答案截图
Count the number of words in a line of string and take it as the return value of the function
Microservice architecture practice: business management background and SSO design: SSO design
Interpretation of new plug-ins | how to enhance authentication capability with forward auth
Calculate the average of N numbers in the index group of X, and return the number that is less than the average and closest to the average through formal parameters
[Error] ld returned 1 exit status
Incomplete line spacing adjustment of formula display in word
Inspirational. In one year, from Xiaobai to entering the core Department of Alibaba, his counter attack
num[i]++
COMP5216 Mobile Computing Assignment 1 - Extending ToDoList app
Screenshot of the answers to C language exercises
LeetCode Algorithm 24. 两两交换链表中的节点