当前位置:网站首页>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

Official website address

  Download installation package

Version introduction

Check if it has been installed mysql And unloading

Check to see if MySQL

MySQL The uninstall

1. close mysql service

2. View the current mysql Installation status

3. Uninstall the installed programs found by the above command

4. Delete mysql Related documents

install

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

4.  see MySQL edition

5. Initialization of services

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

MySQL Sign in

1. For the first time login

2. Change Password

3.  Set up remote login

4. Linux Modify the configuration under

  If this blog is of some help to you , Remember to leave a message + give the thumbs-up + Collection . 


 

Official website address

MySQLhttps://www.mysql.com

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 . 

原网站

版权声明
本文为[Little Zhang free - & gt; Zhang Youbo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/200/202207171609255047.html