Linux installation mysql encountered problems and solutions, installation process

1. When this problem occurs:

The GPG key for source "MySQL 5.7 Community Server" is installed, but not for this package. Please check if the source's public key URL is configured correctly.

One-sentence solution code: rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
Specific details of the problem:

  • Platform: Alibaba Cloud ECS

  • Operating system: CentOS-7\CentOS-8

  • Steps:

    wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm  
    yum -y install mysql57-community-release-el7-10.noarch.rpm  
    #执行这条语句的时候报错
    yum -y install mysql-community-server 
    
         
         
  • Error message:

    从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥
    源 "MySQL 5.7 Community Server" 的 GPG 密钥已安装,但是不适用于此软件包。请检查源的公钥 URL 是否配置正确。
    失败的软件包是:mysql-community-server-5.7.37-1.el7.x86_64
    GPG  密钥配置为:file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    
         
         
  • solution:

    The GPG verification fails. I understand that the public key corresponding to the software package configured on this machine is wrong, and the signature verification fails. (I also don't know at which step in the installation process this public key is automatically configured). I searched for the keyword GPG on the mysql official website and found a solution. The general idea is that if you use a version of rpm above 4.1, in addition to importing the public key of mysql to the configuration of the individual user, you also need to import the public key of mysql to the configuration of the RPM middle.

  • original:

    If you are using RPM 4.1 and it complains about (GPG) NOT OK (MISSING KEYS: GPG#3a79bd29), even though you have imported the MySQL public build key into your own GPG keyring, you need to import the key into the RPM keyring first. RPM 4.1 no longer uses your personal GPG keyring (or GPG itself). Rather, RPM maintains a separate keyring because it is a system-wide application and a user’s GPG public keyring is a user-specific file. To import the MySQL public key into the RPM keyring, first obtain the key, then use rpm --import to import the key. For example:

    $> gpg --export -a 3a79bd29 > 3a79bd29.asc
    $> rpm --import 3a79bd29.asc
    
         
         

    Alternatively, rpm also supports loading the key directly from a URL:

    $> rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
    
         
         
  • Remarks: The above original text commands are only applicable to mysql5.7. For other versions, please click the original text link , select the corresponding version, and view the solution

2. When this problem occurs

This problem is caused by the conflict of installing mysql version. After installing mysql, it fails to start, and various errors occur. The mysql file does not have permission.

Solution: first delete all mysql packages on the machine, and then reinstall mysql5.7

 yum list installed | grep mysql
to view the packages of MySQL installed originally, and delete them through yum -y remove mysql

3. When this problem occurs

mysql中Table is read only

If some problems suddenly appear in the database in use, 
just execute the following command under Linux. Of course, you need to find your mysql directory 

 

in linux 

code show as below:

/usr/local/mysql/bin/mysqladmin -u root -p flush-tables 


In windows, 
you can execute lush-tables in cmd, 
or you can directly use the repair table to modify it in phpmyadmin  .


If it is to import and restore data 
, so chmod all table files under the database folder to 777, and chown to "_mysql", but this time the problem More seriously, the actual table in drupal is crached. No way, Google immediately and found that it is actually quite easy to solve. 
First, find the location of mysqladmin, usually under mysql/bin, and then run the command:

code show as below:

./mysqladmin -u root -p flush-tables 


After entering the password of the root account, it will be fine immediately, without any prompt, reopen drupal, everything is normal. 
Through this time, I also found the correct permission setting of the database file: the database folder under data is 700, the table file is 660, and all files should be owned by mysql.

Standard installation steps:

1. Confirm whether MySQL has been installed before, whether there are previous files in var/lib/mysql, and if so, it will be affected.

Guess you like

Origin blog.csdn.net/qq_27246521/article/details/123048219