当前位置:网站首页>Installation and use of MySQL under Linux
Installation and use of MySQL under Linux
2022-07-19 12:22:00 【Little Zhang free - & gt; Zhang Youbo】
Catalog
Check if it has been installed mysql And unloading
2. View the current mysql Installation status
3. Uninstall the installed programs found by the above command
4. Delete mysql Related documents
CentOS7 Lower inspection MySQL rely on
1. Check /tmp Temporary directory permissions ( essential )
2. Before the installation , Checking depends on
CentOS7 Next MySQL setup script
1. Copy the installer to /opt Under the table of contents
2. Screenshot of the installation process
3. If the installation is completed, an error is reported , The solution is as follows
6. Check the password : Copy now , Log in to mysql after , Need to change password
7. start-up MySQL, Check the status
8. see MySQL Whether the service starts automatically
4. Linux Modify the configuration under
Official website address
MySQL Community Server Community version , Free open source , Free download , But no official technical support , Apply to
Most ordinary users .
MySQL Enterprise Edition Enterprise version , Pay for , Can't download online , You can try 30 God . More
Functions and more complete technical support , It is more suitable for enterprise customers with high requirements for database function and reliability .
MySQL Cluster Cluster version , Free open source . It is used to set up cluster servers , You can put a few MySQL Server Encapsulate into a
Server. It needs to be used on the basis of community version or enterprise version .
MySQL Cluster CGE Advanced clustering , Pay for .
Download installation package
Version introduction
Check if it has been installed mysql And unloading
Check to see if MySQL
If you use rpm install , Check the RPM PACKAGE:
rpm -qa | grep -i mysql # -i Ignore case
Check mysql service
systemctl status mysqld.service
MySQL The uninstall
1. close mysql service
systemctl stop mysqld.service
2. View the current mysql Installation status
rpm -qa | grep -i mysql
# or
yum list installed | grep mysql
3. Uninstall the installed programs found by the above command
yum remove mysql-xxx mysql-xxx mysql-xxx mysqk-xxxx
Be sure to unload clean , Repeat rpm -qa | grep -i mysql
Confirm whether there are unloading residues
4. Delete mysql Related documents
# lookup
find / -name mysql
# Delete
rm -rf xxx
5. Delete my.cnf
rm -rf /etc/my.cnf
install
CentOS7 Lower inspection MySQL rely on
1. Check /tmp Temporary directory permissions ( essential )
because mysql During installation , Will pass mysql The user is in /tmp New under the directory tmp_db file , So please give /tmp Greater authority . perform :
chmod -R 777 /tmp
2. Before the installation , Checking depends on
rpm -qa|grep libaio
rpm -qa|grep net-tools
CentOS7 Next MySQL setup script
1. Copy the installer to /opt Under the table of contents
stay mysql The installation file directory of :( It must be carried out in order )
rpm -ivh mysql-community-common-8.0.25-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.25-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.25-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm
rpm
yes Redhat Package Manage abbreviation , adopt RPM Management of , Users can wrap the source code as rpm Is the file form of the extension , Easy to install .
-i
, --install Install package
-v
, --verbose Provide more detailed information output
-h
, --hash The hash mark is listed when the package is installed ( and -v The effect is better when used together ), Show the progress bar
2. Screenshot of the installation process
2.1 If an error is reported during installation , The solution is as follows
[[email protected] mysql]# rpm -ivh mysql-community-client-plugins-8.0.29-1.el8.x86_64.rpm
warning: mysql-community-client-plugins-8.0.29-1.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
error: Failed dependencies:
libc.so.6(GLIBC_2.25)(64bit) is needed by mysql-community-client-plugins-8.0.29-1.el8.x86_64
libcrypto.so.1.1()(64bit) is needed by mysql-community-client-plugins-8.0.29-1.el8.x86_64
libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) is needed by mysql-community-client-plugins-8.0.29-1.el8.x86_64
libcrypto.so.1.1(OPENSSL_1_1_1)(64bit) is needed by mysql-community-client-plugins-8.0.29-1.el8.x86_64
libssl.so.1.1()(64bit) is needed by mysql-community-client-plugins-8.0.29-1.el8.x86_64
libstdc++.so.6(CXXABI_1.3.8)(64bit) is needed by mysql-community-client-plugins-8.0.29-1.el8.x86_64
libstdc++.so.6(CXXABI_1.3.9)(64bit) is needed by mysql-community-client-plugins-8.0.29-1.el8.x86_64
libstdc++.so.6(GLIBCXX_3.4.20)(64bit) is needed by mysql-community-client-plugins-8.0.29-1.el8.x86_64
libstdc++.so.6(GLIBCXX_3.4.21)(64bit) is needed by mysql-community-client-plugins-8.0.29-1.el8.x86_64
The solution is as follows : Force installation of this version
After checking the information Find out This is because yum An older version of GPG keys Caused by , from rpm edition 4.1 after , When installing or upgrading a package, the signature of the package is automatically checked . Just add -force --nodeps You can solve the problem !
3. If the installation is completed, an error is reported , The solution is as follows
Screenshot of error reporting
The reason is that I downloaded it wrong mysql Version of the ,
linux The version is 7.6
mysql The download version is Red Hat Enterprise Linux 8 / Oracle Linux 8 (x86, 64-bit), RPM Bundle
Should be
Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit), RPM Bundle
Solve after downloading again ( The download process must be careful 、 careful ):
4. see MySQL edition
mysql --version
# or
mysqladmin --version
5. Initialization of services
In order to ensure that the owner of database directories and files is mysql The logged in user , If you are root Identity running mysql service , You need to perform the following command initialization :
mysqld --initialize --user=mysql
explain : --initialize Options default to “ Security ” Mode to initialize , Will be root The user generates a password and will The password is marked as expired
, After logging in, you need to set a new password . Generated Temporary password
Will record a copy in the log .
6. Check the password : Copy now , Log in to mysql after , Need to change password
cat /var/log/mysqld.log
[email protected]: Followed by the initialization password
7. start-up MySQL, Check the status
# Add do not add .service Suffixes are OK
start-up :systemctl start mysqld.service
close :systemctl stop mysqld.service
restart :systemctl restart mysqld.service
Check the status :systemctl status mysqld.service
8. see MySQL Whether the service starts automatically
systemctl list-unit-files|grep mysqld.service
If not enabled You can run the following command to set the auto start
systemctl enable mysqld.service
If you want to avoid self starting , Run the following command
systemctl disable mysqld.service
MySQL Sign in
1. For the first time login
adopt mysql -hlocalhost -P3306 -uroot -p
Log in , stay Enter password: Enter the initialization password
2. Change Password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
3. Set up remote login
In use SQLyog or Navicat Configure remote connections in Mysql The following error messages are encountered when the database , This is because Mysql Configured... Caused by unsupported remote connection .
1. Confirm the network
1. Use... On remote machines ping ip Address Ensure smooth network
2. Use... On remote machines telnet command Ensure that the port number is open
visit
2. Turn off the firewall or open ports
Mode one : Turn off firewall
# Turn on the firewall
systemctl start firewalld.service
# View firewall status
systemctl status firewalld.service
# Turn off firewall
systemctl stop firewalld.service
# Set boot to enable firewall
systemctl enable firewalld.service
# Set boot disable firewall
systemctl disable firewalld.service
Mode two : Open ports
## Check the open port number
firewall-cmd --list-all
## Set the open port number
firewall-cmd --add-service=http --permanent
firewall-cmd --add-port=3306/tcp --permanent
## service iptables restart
firewall-cmd --reload
If it's a cloud server , You also need to add rules
4. Linux Modify the configuration under
Sign in mysql, Modify allow remote login
use mysql;
select Host,User from user;
update user set host = '%' where user ='root';
flush privileges; ## Refresh configuration
Before modifying the configuration
After modifying the configuration
%
It's a wildcard , If Host=192.168.1.%, So that means as long as it's IP Address prefix is “192.168.1.” All clients of can connect . If Host=%
, Express all IP All have connection permission
Be careful : In a production environment, you can't save host Set to %, There will be security problems , Specific settings can be set according to the production environment IP Set it up .
The article is now installed , Thank you for reading , If this installation is not successful , Please leave me a message , Let's make progress together .
If this blog is of some help to you , You remember Leaving a message. + give the thumbs-up + Collection Oh .
边栏推荐
猜你喜欢
人大、微软等提出InclusiveFL:异构设备上的包容性联邦学习
SwiftUI 颜色教程大全之中创建自定义调色板
机器学习(上)吴恩达
数据库每日一题---第25天:银行账户概要 II
Energy saving resource allocation strategy based on time-varying graph in satellite networks
Microcomputer principle and technology Interface Experiment four subroutines and interrupt experiment
C language drawing example - flower pattern
第五天笔记
Valid bracket sequence of "Niuke | daily question"
C language drawing example - palette
随机推荐
Overview of the application of air, space and sea Association
Travail du quatrième jour
hcip第四天笔记
文件一键备份
psd.js 解析PSD文件
3. Golang string type
电路故障的分析简略
Day 1 Experiment
WAV和PCM的关系和区别
2022 low voltage electrician examination questions and online simulation examination
如何应用小程序容器技术开发Hybrid App
HCIP(5)
Relationship and difference between wav and PCM
Opencv tutorial 03: how to track an object in a video
HCIP(4)
Example of C language drawing - 20 examples of chromatic diagram
MIHA tour 2023 autumn recruitment officially begins ~ early approval has the opportunity to avoid written examination!
NPC, Microsoft, etc. proposed inclusivefl: inclusive federal learning on heterogeneous devices
详细分析一个ROS2 CMakeLists.txt文件
zabbix-snmp监控