当前位置:网站首页>Install MySQL using Yum for Linux

Install MySQL using Yum for Linux

2022-06-24 17:28:00 Yue Lai

One 、 Preparation before installation

1、 Check if... Has been installed mysql, Carry out orders 
rpm -qa | grep mysql
 If it already exists , Then execute the delete command   The back is Mysql Catalog 
rpm -e --nodeps mysql-xxxx

2、 Query all Mysql The corresponding folder 
whereis mysqlm
find / -name mysql

 Delete related directory or file 
rm -rf /usr/bin/mysql /usr/include/mysql /data/mysql /data/mysql/mysql 

 Verify that the deletion is complete 
whereis mysqlm
find / -name mysql

3、 Check mysql Whether user groups and users exist , without , Create 
cat /etc/group | grep mysql
cat /etc/passwd |grep mysql
groupadd mysql
useradd -r -g mysql mysql

Two 、yum install

1、yum install mysql

2、yum install mysql-server   # An error is as follows 
Last metadata expiration check: 0:25:55 ago on Mon 21 Feb 2022 10:27:14 AM CST.
No match for argument: mysql-server
Error: Unable to find a match: mysql-server

# reason :CentOS7 Bring with you MariaDB instead of MySQL,MariaDB and MySQL It's also Kaiyuan's database 
# terms of settlement : If you have to install MySQL, You must first add mysql Community repo, Carry out orders :
sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

Retrieving http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-release-el7-5    ################################# [100%]
   
#  After the execution , Then continue :
yum install mysql-server 

3、yum install mysql-devel

4、yum install -y mariadb-server

3、 ... and 、 start-up

1、
mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)  modify  /etc/my.cnf # add to  [client] port=3306 socket=/var/lib/mysql/mysql.sock user=mysql 2、 #service mysqld start#  Running stuck  Redirecting to /bin/systemctl start mysqld.service ^C service mysqld status systemctl status mysqld.service ● mysqld.service - MySQL Community Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: activating (start-post) since Mon 2022-02-21 14:05:51 CST; 6min ago Process: 63686 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS) Process: 63671 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 63686 (code=exited, status=0/SUCCESS); : 63687 (mysql-systemd-s) Tasks: 2 Memory: 17.6M CGroup: /system.slice/mysqld.service └─control ├─63687 /bin/bash /usr/bin/mysql-systemd-start post └─69856 sleep 1 Feb 21 14:05:51 xxx systemd[1]: Starting MySQL Community Server... Feb 21 14:05:51 xxx mysqld_safe[63686]: 220221 14:05:51 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'. Feb 21 14:05:51 xxx mysqld_safe[63686]: 220221 14:05:51 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 2.1、 #  see /var/log/mariadb/mariadb.log 2022-02-21 14:34:29 92642 [Note] Plugin 'FEDERATED' is disabled. /usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
2022-02-21 14:34:29 92642 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. # terms of settlement : /usr/bin/mysql_install_db --user=mysql Installing MySQL system tables...2022-02-21 14:38:39 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2022-02-21 14:38:39 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 2022-02-21 14:38:39 0 [Note] /usr/sbin/mysqld (mysqld 5.6.51) starting as process 96247 ... 2022-02-21 14:38:39 96247 [Note] InnoDB: Using atomics to ref count buffer pool pages 2022-02-21 14:38:39 96247 [Note] InnoDB: The InnoDB memory heap is disabled 2022-02-21 14:38:39 96247 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2022-02-21 14:38:39 96247 [Note] InnoDB: Memory barrier is not used 2022-02-21 14:38:39 96247 [Note] InnoDB: Compressed tables use zlib 1.2.11 2022-02-21 14:38:39 96247 [Note] InnoDB: Using Linux native AIO 2022-02-21 14:38:39 96247 [Note] InnoDB: Using CPU crc32 instructions 2022-02-21 14:38:39 96247 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2022-02-21 14:38:39 96247 [Note] InnoDB: Completed initialization of buffer pool 2022-02-21 14:38:39 96247 [Note] InnoDB: Highest supported file format is Barracuda. 2022-02-21 14:38:39 96247 [Note] InnoDB: 128 rollback segment(s) are active. 2022-02-21 14:38:39 96247 [Note] InnoDB: Waiting for purge to start 2022-02-21 14:38:39 96247 [Note] InnoDB: 5.6.51 started; log sequence number 1600627 2022-02-21 14:38:39 96247 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work. 2022-02-21 14:38:39 96247 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work. 2022-02-21 14:38:39 96247 [Note] Binlog end 2022-02-21 14:38:39 96247 [Note] InnoDB: FTS optimize thread exiting. 2022-02-21 14:38:39 96247 [Note] InnoDB: Starting shutdown... 2022-02-21 14:38:41 96247 [Note] InnoDB: Shutdown completed; log sequence number 1626007 OK Filling help tables...2022-02-21 14:38:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2022-02-21 14:38:41 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 2022-02-21 14:38:41 0 [Note] /usr/sbin/mysqld (mysqld 5.6.51) starting as process 96282 ... 2022-02-21 14:38:41 96282 [Note] InnoDB: Using atomics to ref count buffer pool pages 2022-02-21 14:38:41 96282 [Note] InnoDB: The InnoDB memory heap is disabled 2022-02-21 14:38:41 96282 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2022-02-21 14:38:41 96282 [Note] InnoDB: Memory barrier is not used 2022-02-21 14:38:41 96282 [Note] InnoDB: Compressed tables use zlib 1.2.11 2022-02-21 14:38:41 96282 [Note] InnoDB: Using Linux native AIO 2022-02-21 14:38:41 96282 [Note] InnoDB: Using CPU crc32 instructions 2022-02-21 14:38:41 96282 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2022-02-21 14:38:41 96282 [Note] InnoDB: Completed initialization of buffer pool 2022-02-21 14:38:41 96282 [Note] InnoDB: Highest supported file format is Barracuda. 2022-02-21 14:38:41 96282 [Note] InnoDB: 128 rollback segment(s) are active. 2022-02-21 14:38:41 96282 [Note] InnoDB: Waiting for purge to start 2022-02-21 14:38:41 96282 [Note] InnoDB: 5.6.51 started; log sequence number 1626007 2022-02-21 14:38:41 96282 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work. 2022-02-21 14:38:41 96282 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work. 2022-02-21 14:38:41 96282 [Note] Binlog end 2022-02-21 14:38:41 96282 [Note] InnoDB: FTS optimize thread exiting. 2022-02-21 14:38:41 96282 [Note] InnoDB: Starting shutdown... 2022-02-21 14:38:43 96282 [Note] InnoDB: Shutdown completed; log sequence number 1626017 OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h docker-ce011162004053.nt12 password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl Please report any problems at http://bugs.mysql.com/ The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com New default config file was created as /usr/my.cnf and will be used by default by the server when you start it. You may edit this file to change server settings WARNING: Default config file /etc/my.cnf exists on the system This file will be read by default by the MySQL server If you do not want to use this, either remove it, or use the --defaults-file argument to mysqld_safe when starting the server 2.2、 #mariadb.log Another error in  Can't start server: can't check PID filepath: No such file or directory 220221 14:34:30 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended  terms of settlement : mkdir -p /var/run/mariadb/ chown -R mysql:mysql /var/run/mariadb/ service mysql start #  normal  Redirecting to /bin/systemctl start mysql.service service mysql status #  normal  Redirecting to /bin/systemctl status mysql.service ● mysqld.service - MySQL Community Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2022-02-21 14:54:13 CST; 31min ago Process: 112292 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS) Process: 112276 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 112291 (mysqld_safe) Tasks: 23 Memory: 119.3M CGroup: /system.slice/mysqld.service ├─112291 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─112457 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock Feb 21 14:54:12 xxx systemd[1]: Starting MySQL Community Server... Feb 21 14:54:12 xxx mysqld_safe[112291]: 220221 14:54:12 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Feb 21 14:54:12 xxx mysqld_safe[112291]: 220221 14:54:12 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

mysql  #  Enter normally 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

3、
mysqladmin -u root password   # Set the password 


Four 、 Reference documents

1、https://www.cnblogs.com/linglei/p/14519416.html

2、https://www.cnblogs.com/xieyupeng/p/8945297.html

3、https://blog.csdn.net/cy309173854/article/details/79929468

4、https://www.cnblogs.com/jie1521/p/10286604.html

5、https://www.cnblogs.com/linglei/p/14519416.html

6、http://www.geekapp.cn/archives/390.html

7、https://www.jb51.net/article/174244.htm

原网站

版权声明
本文为[Yue Lai]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202211554399516.html