最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux使用yum安裝mysql的方式

 更新時(shí)間:2025年06月07日 09:57:16   作者:岳來  
這篇文章主要介紹了Linux使用yum安裝mysql的方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

一、安裝前準(zhǔn)備

1、檢查是否已經(jīng)安裝過mysql,執(zhí)行命令
rpm -qa | grep mysql
如果已存在,則執(zhí)行刪除命令 后邊為Mysql目錄
rpm -e --nodeps mysql-xxxx

2、查詢所有Mysql對應(yīng)的文件夾
whereis mysqlm
find / -name mysql

刪除相關(guān)目錄或文件
rm -rf /usr/bin/mysql /usr/include/mysql /data/mysql /data/mysql/mysql 

驗(yàn)證是否刪除完畢
whereis mysqlm
find / -name mysql

3、檢查mysql用戶組和用戶是否存在,如果沒有,則創(chuàng)建
cat /etc/group | grep mysql
cat /etc/passwd |grep mysql
groupadd mysql
useradd -r -g mysql mysql

二、yum安裝

1、yum install mysql

2、yum install mysql-server   #報(bào)錯(cuò)如下
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

#原因:CentOS7自帶有MariaDB而不是MySQL,MariaDB和MySQL一樣也是開元的數(shù)據(jù)庫
#解決辦法:如果必須要安裝MySQL,首先必須添加mysql社區(qū)repo,執(zhí)行命令:
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%]
   
# 執(zhí)行完后,則繼續(xù)執(zhí)行:
yum install mysql-server 

3、yum install mysql-devel

4、yum install -y mariadb-server

三、啟動

1、
mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)


修改 /etc/my.cnf
#添加
[client]
port=3306
socket=/var/lib/mysql/mysql.sock

user=mysql

2、
#service mysqld start# 運(yùn)行卡住
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、
# 查看/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.

#解決辦法:
/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中另一個(gè)報(bào)錯(cuò)
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

解決辦法:
mkdir -p /var/run/mariadb/
chown -R mysql:mysql /var/run/mariadb/


service mysql start  # 正常
Redirecting to /bin/systemctl start mysql.service

service mysql status  # 正常
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  # 正常進(jìn)入
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   #設(shè)置密碼

四、另一種方法安裝

4.1、安裝mysql

yum -y install mariadb  mariadb-devel  mariadb-server

4.2、啟動mysql 服務(wù)

systemctl start mariadb.service

4.3、設(shè)置密碼

#mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> select host,user from mysql.user;
+-----------------------------+------+
| host                        | user |
+-----------------------------+------+
| 127.0.0.1                   | root |
| ::1                         | root |
| xxx                  |      |
| xxx                         | root |
| localhost                   |      |
| localhost                   | root |
+-----------------------------+------+
6 rows in set (0.00 sec)

MariaDB [mysql]> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+

MariaDB [mysql]> UPDATE user SET password=PASSWORD('xxxxx') WHERE user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> exit;
Bye

[root@docker-ce011166091186.na131 /home/gyy01167504]
#mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 在Linux開發(fā)板中使用.NET實(shí)現(xiàn)音頻錄制與播放功能

    在Linux開發(fā)板中使用.NET實(shí)現(xiàn)音頻錄制與播放功能

    本文將以Linux開發(fā)板為基礎(chǔ),使用ALSA音頻框架和C#語言,演示如何實(shí)現(xiàn)基礎(chǔ)的音頻錄制與播放功能,文中通過代碼示例講解的非常詳細(xì),需要的朋友可以參考下
    2025-03-03
  • Centos7配置阿里云yum源及epel源過程

    Centos7配置阿里云yum源及epel源過程

    文章主要介紹了Yum軟件包管理器的基礎(chǔ)知識,以及如何配置阿里云的yum源和epel源,包括備份原有配置文件、下載阿里云配置文件并重建緩存等步驟
    2026-04-04
  • Linux上虛擬機(jī)顯示網(wǎng)絡(luò)不可用的解決方法

    Linux上虛擬機(jī)顯示網(wǎng)絡(luò)不可用的解決方法

    這篇文章主要介紹了Linux上虛擬機(jī)顯示網(wǎng)絡(luò)不可用的解決方法,文中通過圖文結(jié)合的方式講解的非常詳細(xì),對大家解決問題有一定的幫助,需要的朋友可以參考下
    2024-12-12
  • Linux使用pt-slave-restart監(jiān)控多個(gè)從庫的Shell腳本案例

    Linux使用pt-slave-restart監(jiān)控多個(gè)從庫的Shell腳本案例

    本文介紹了如何編寫并使用一個(gè)基于pt-slave-restart的Shell腳本,實(shí)現(xiàn)對多個(gè)MySQL從庫復(fù)制狀態(tài)的靈活監(jiān)控,支持多種配置方式、參數(shù)覆蓋、錯(cuò)誤處理及守護(hù)進(jìn)程等功能,便于高效管理數(shù)據(jù)庫復(fù)制,需要的朋友可以參考下
    2025-10-10
  • CentOS6.6安裝CloudStack4.8

    CentOS6.6安裝CloudStack4.8

    CloudStack是一個(gè)開源的具有高可用性及擴(kuò)展性的云計(jì)算平臺。接下來通過本文給大家介紹CentOS6.6安裝CloudStack4.8的方法,感興趣的朋友一起看看吧
    2016-10-10
  • CentOS 7.2配置Apache服務(wù)httpd(上)

    CentOS 7.2配置Apache服務(wù)httpd(上)

    這篇文章主要為大家詳細(xì)介紹了CentOS 7.2配置Apache服務(wù) httpd上篇,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Windows7下Linux雙操作系統(tǒng)安裝圖文教程

    Windows7下Linux雙操作系統(tǒng)安裝圖文教程

    這篇文章主要為大家詳細(xì)介紹了Windows7下Linux雙操作系統(tǒng)安裝圖文教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-07-07
  • 詳解Linux中關(guān)于引號的那些事

    詳解Linux中關(guān)于引號的那些事

    這篇文章主要給大家介紹了關(guān)于Linux中關(guān)于引號的那些事,文中詳細(xì)介紹了關(guān)于引號、單引號和雙引號、引用單個(gè)字符以及反斜杠的其他使用技巧等的相關(guān)內(nèi)容,介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧。
    2017-06-06
  • Linux(CentOS)??同步服務(wù)器chrony的安裝配置和常用命令

    Linux(CentOS)??同步服務(wù)器chrony的安裝配置和常用命令

    Chrony是一款開源的網(wǎng)絡(luò)時(shí)間協(xié)議(NTP)客戶端和服務(wù)端軟件,旨在提供高精度的時(shí)間同步功能,相較于傳統(tǒng)的NTP實(shí)現(xiàn)如ntpd,Chrony提供了一些改進(jìn)和優(yōu)勢,包括更快的同步速度、低延遲、低CPU占用和低內(nèi)存消耗,本文介紹Linux(CentOS)??同步服務(wù)器chrony的安裝配置和常用命令
    2024-06-06
  • Linux刪除文件名包含無效編碼字符文件的方法

    Linux刪除文件名包含無效編碼字符文件的方法

    本文介紹了在Linux中處理文件名包含無效編碼字符或特殊不可見字符的方法,包括確認(rèn)文件名問題、刪除無效編碼文件的幾種方法,如通過inode編號、通配符匹配等,需要的朋友可以參考下
    2026-01-01

最新評論

东莞市| 灌云县| 仁布县| 辽宁省| 漳州市| 南充市| 临武县| 湟源县| 萍乡市| 孝义市| 南靖县| 八宿县| 凤山市| 乐陵市| 双流县| 六枝特区| 茌平县| 农安县| 武平县| 青岛市| 铅山县| 西城区| 康平县| 都安| 巫溪县| 银川市| 繁昌县| 凯里市| 蒙阴县| 平武县| 玉溪市| 玛曲县| 左云县| 罗田县| 平塘县| 龙川县| 庆元县| 郯城县| 黑河市| 宁强县| 乌苏市|