国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

如何在Linux系統(tǒng)中安裝MySQL數(shù)據(jù)庫(kù)

這篇具有很好參考價(jià)值的文章主要介紹了如何在Linux系統(tǒng)中安裝MySQL數(shù)據(jù)庫(kù)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

(一)、準(zhǔn)備

1、Linux環(huán)境

視頻教程:https://www.bilibili.com/video/BV15m4y1d7ZP

2、檢查內(nèi)存

5.6及以上版本的MySQL要求Linux系統(tǒng)虛擬內(nèi)存不能小于1G,否則MySQL可能無(wú)法運(yùn)行。

3、卸載mariadb
[root@localhost ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
[root@localhost ~]#

(二)、安裝

1、下載

下載地址:https://mirrors.aliyun.com/mysql/MySQL-8.0,這里下載mysql-8.0.28-el7-x86_64.tar.gz

2、上傳

將mysql-5.7.30-el7-x86_64.tar.gz壓縮文件上傳至/opt目錄;

3、解壓

將MySQL壓縮文件解壓至/usr/local目錄

[root@localhost ~]# tar -zxvf /opt/mysql-8.0.28-el7-x86_64.tar.gz -C /usr/local
4、重命名

將MySQL根目錄重命名為mysql

[root@localhost ~]# mv /usr/local/mysql-8.0.28-el7-x86_64 /usr/local/mysql

注意:必須重命名為mysql,否則無(wú)法啟動(dòng)

5、刪除

刪除壓縮文件

[root@localhost ~]# rm -f /opt/mysql-8.0.28-el7-x86_64.tar.gz
6、創(chuàng)建目錄

/usr/local/mysql根目錄下創(chuàng)建data文件夾

[root@localhost ~]# mkdir /usr/local/mysql/data
7、環(huán)境變量

a、編輯/etc/profile文件,內(nèi)容如下:

export PATH=/usr/local/mysql/bin:$PATH

b、重載/etc/profile文件:source /etc/profile

c、查看PATH值:echo $PATH

8、修改配置

a、查找mysql配置路徑

[root@localhost ~]# mysql --help | grep 'my.cnf'
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 
[root@localhost ~]# 

b、執(zhí)行vi /etc/my.cnf

c、點(diǎn)擊I鍵,復(fù)制并粘貼如下配置:

[mysql]
# 設(shè)置mysql客戶端默認(rèn)字符集
default-character-set=utf8

[mysqld]
#設(shè)置端口
port=3306
socket=/tmp/mysql.sock
#設(shè)置mysql根目錄
basedir=/usr/local/mysql
#設(shè)置數(shù)據(jù)庫(kù)的數(shù)據(jù)存放目錄
datadir=/usr/local/mysql/data
#設(shè)置最大連接數(shù)
max_connections=200
#設(shè)置mysql服務(wù)端字符集,默認(rèn)為latin1
character-set-server=UTF8MB4
#設(shè)置默認(rèn)存儲(chǔ)引擎
default-storage-engine=INNODB
#設(shè)置密碼永不過(guò)期
default_password_lifetime=0
#設(shè)置 server接受的數(shù)據(jù)包大小
max_allowed_packet=16M
9、用戶與用戶組

a、添加 mysql 組

[root@localhost ~]# groupadd mysql

b、添加 mysql 用戶

[root@localhost ~]# useradd -r -g mysql mysql

c、變更用戶和用戶組

[root@localhost ~]# chown -R mysql:mysql /usr/local/mysql
10、初始化
[root@localhost ~]# mysqld --initialize --user=mysql
2022-11-17T03:34:13.745049Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.28) initializing of server in progress as process 20052
2022-11-17T03:34:13.868756Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-11-17T03:34:15.109952Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-11-17T03:34:16.778334Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pH6T0ltJ6y,N
[root@localhost ~]#

說(shuō)明:pH6T0ltJ6y,N 為臨時(shí)密碼

11、其它
# 安裝SSL
[root@localhost ~]# mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
# 添加權(quán)限
[root@localhost ~]# chmod -R a+r /usr/local/mysql/data/server-key.pem

(三)、配置

1、開(kāi)機(jī)啟動(dòng)

a、復(fù)制啟動(dòng)腳本到資源目錄

[root@localhost ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld

b、mysqld文件添加執(zhí)行權(quán)限

[root@localhost ~]# chmod +x /etc/rc.d/init.d/mysqld

c、mysqld服務(wù)添加至系統(tǒng)服務(wù)

[root@localhost ~]# chkconfig --add mysqld

d、查詢mysqld服務(wù)

[root@localhost ~]# chkconfig --list mysqld

注:該輸出結(jié)果只顯示 SysV 服務(wù),并不包含
原生 systemd 服務(wù)。SysV 配置數(shù)據(jù)
可能被原生 systemd 配置覆蓋。 

      要列出 systemd 服務(wù),請(qǐng)執(zhí)行 'systemctl list-unit-files'。
      查看在具體 target 啟用的服務(wù)請(qǐng)執(zhí)行
      'systemctl list-dependencies [target]'。

mysqld          0:關(guān)    1:關(guān)    2:開(kāi)    3:開(kāi)    4:開(kāi)    5:開(kāi)    6:關(guān)
[root@localhost ~]# 

e、啟動(dòng) mysqld服務(wù)

[root@localhost ~]# service mysqld start
2、開(kāi)放端口

a、添加端口

[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent

b、重新加載

[root@localhost ~]# firewall-cmd --reload
3、修改密碼

初次登錄MySQL數(shù)據(jù)庫(kù)需要重置密碼才能繼續(xù)后面的數(shù)據(jù)庫(kù)操作,步驟如下:

[root@localhost ~]# mysql -uroot -p
Enter password: 輸入臨時(shí)密碼
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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

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

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
[root@localhost ~]#
4、允許遠(yuǎn)程連接

MySQL數(shù)據(jù)庫(kù)默認(rèn)不允許遠(yuǎn)程連接,可通過(guò)如下步驟允許遠(yuǎn)程連接:

[root@localhost ~]# mysql -uroot -p
Enter password: 輸入密碼
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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

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

mysql> 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
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

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

mysql> quit
Bye
[root@localhost ~]#

(四)、問(wèn)題

1、問(wèn)題一

問(wèn)題:使用mysql -u root -p命令登陸MySQL數(shù)據(jù)庫(kù)時(shí)提示如下錯(cuò)誤:

SQLyog遠(yuǎn)程連接MySQL,提示如下錯(cuò)誤:

如何在Linux系統(tǒng)中安裝MySQL數(shù)據(jù)庫(kù)

方案:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-444987.html

[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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

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

mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
[root@localhost ~]#

到了這里,關(guān)于如何在Linux系統(tǒng)中安裝MySQL數(shù)據(jù)庫(kù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 1.在CentOS中安裝Mysql數(shù)據(jù)庫(kù)

    1.在CentOS中安裝Mysql數(shù)據(jù)庫(kù)

    1.下載Mysql社區(qū)版 (備注說(shuō)明Windows下載,則需要上傳至/home/mysql/目錄下) 登錄Mysql官網(wǎng):MySQL? ? ?點(diǎn)擊“DOWNLOADS” 選擇“MySQL Community (GPL) Downloads” 選擇社區(qū)服務(wù)器版,即點(diǎn)擊“MySQL Community Server” 選擇對(duì)應(yīng)的版本,本文是計(jì)劃安裝在CentOS上,所以,選擇通用版【小伙伴們,可

    2023年04月13日
    瀏覽(22)
  • linux中安裝ES數(shù)據(jù)庫(kù)

    linux中安裝ES數(shù)據(jù)庫(kù)

    jdk安裝 Elasticsearch 是一個(gè)開(kāi)源的搜索引擎,建立在全文搜索引擎庫(kù) Apache Lucene 基礎(chǔ)之上 用 Java 編寫(xiě)的,它的內(nèi)部使用 Lucene 做索引與搜索,但是它的目的是使全文檢索變得簡(jiǎn)單, 通過(guò)隱藏 Lucene 的復(fù)雜性,取而代之的提供一套簡(jiǎn)單一致的 RESTful API。 Elasticsearch 不僅僅只是一個(gè)

    2023年04月09日
    瀏覽(18)
  • linux系統(tǒng)--------------mysql數(shù)據(jù)庫(kù)管理

    linux系統(tǒng)--------------mysql數(shù)據(jù)庫(kù)管理

    目錄 一、SQL語(yǔ)句 1.1SQL語(yǔ)言分類 1.2查看數(shù)據(jù)庫(kù)信息? ? 1.3登錄到你想登錄的庫(kù) 1.4查看數(shù)據(jù)庫(kù)中的表信息 1.5顯示數(shù)據(jù)表的結(jié)構(gòu)(字段) 1.5.1數(shù)據(jù)表的結(jié)構(gòu) 1.5.2常用的數(shù)據(jù)類型: 二、關(guān)系型數(shù)據(jù)庫(kù)的四種語(yǔ)言 2.1DDL:數(shù)據(jù)定義語(yǔ)言,用于創(chuàng)建數(shù)據(jù)庫(kù)對(duì)象,如庫(kù)、表、索引等 2.1.1庫(kù)

    2024年03月24日
    瀏覽(22)
  • 如何在Linux用Docker部署MySQL數(shù)據(jù)庫(kù)并遠(yuǎn)程訪問(wèn)本地?cái)?shù)據(jù)庫(kù)

    如何在Linux用Docker部署MySQL數(shù)據(jù)庫(kù)并遠(yuǎn)程訪問(wèn)本地?cái)?shù)據(jù)庫(kù)

    本文主要介紹如何使用Docker部署MySQL,并結(jié)合cpolar內(nèi)網(wǎng)穿透工具實(shí)現(xiàn)遠(yuǎn)程訪問(wèn)本地?cái)?shù)據(jù)庫(kù)。 Docker提供了一個(gè)輕量級(jí)的容器化解決方案,可以更好的簡(jiǎn)化數(shù)據(jù)庫(kù)的部署過(guò)程。讓創(chuàng)建和管理MySQL數(shù)據(jù)庫(kù)變得更簡(jiǎn)單快捷。下面就來(lái)分享一下具體的部署過(guò)程,并提出一些需要注意的事

    2024年03月10日
    瀏覽(29)
  • Linux高級(jí)管理--安裝MySQL數(shù)據(jù)庫(kù)系統(tǒng)

    Linux高級(jí)管理--安裝MySQL數(shù)據(jù)庫(kù)系統(tǒng)

    ????????MySQL.是一個(gè)真正的多線程、多用戶的SQL數(shù)據(jù)庫(kù)服務(wù),憑借其高性能、高可靠和易于使 用的特性,成為服務(wù)器領(lǐng)域中最受歡迎的開(kāi)源數(shù)據(jù)庫(kù)系統(tǒng)。在2008年以前,MySOL項(xiàng)目由MySQL AB公司進(jìn)行開(kāi)發(fā),發(fā)布和支持,之后歷經(jīng)Sun 公司收購(gòu)MySOL AB公司,Oracle公司收購(gòu)Sun公司 的

    2024年02月04日
    瀏覽(49)
  • Linux系統(tǒng)安裝mysql數(shù)據(jù)庫(kù)(超詳細(xì))

    目錄 1、準(zhǔn)備階段???????? 2、具體步驟 2.1、卸載mariadb 2.2、上傳mysql并解壓 2.3、安裝mysql 2.4、查看版本 2.5、啟動(dòng)mysql服務(wù) 2.6、登錄mysql 2.7、修改密碼 2.8、配置mysql遠(yuǎn)程訪問(wèn) 2.9、修改編碼 3、卸載mysql 3.1、查看mysql的安裝情況? 3.2、刪除安裝包? 3.3、在/根目錄下查詢mysql

    2024年02月12日
    瀏覽(21)
  • c++ mysql數(shù)據(jù)庫(kù)編程(linux系統(tǒng))

    c++ mysql數(shù)據(jù)庫(kù)編程(linux系統(tǒng))

    ubuntu安裝mysql(圖文詳解)-CSDN博客 https://blog.csdn.net/qq_58158950/article/details/135667062?spm=1001.2014.3001.5501 //打印錯(cuò)誤信息? 這段代碼是一個(gè)宏定義,它定義了一個(gè)名為 LOG 的宏。 __FILE__ ?是一個(gè)預(yù)定義宏,它會(huì)在編譯時(shí)被替換為當(dāng)前源文件的文件名(包括路徑)。 __LINE__ ?也是一個(gè)

    2024年01月21日
    瀏覽(26)
  • Linux系統(tǒng)MySQL數(shù)據(jù)庫(kù)的備份及應(yīng)用

    Linux系統(tǒng)MySQL數(shù)據(jù)庫(kù)的備份及應(yīng)用

    本節(jié)主要學(xué)習(xí)了MySQL數(shù)據(jù)庫(kù)的備份:概念,數(shù)據(jù)備份的重要性,造成數(shù)據(jù)丟失的原因,備份的類型,常見(jiàn)的備份方法,實(shí)例與應(yīng)用等。 目錄 一、概述 二、數(shù)據(jù)備份的重要性 三、造成數(shù)據(jù)丟失的原因 四、備份類型 1、物理與邏輯角度 ①物理備份—對(duì)數(shù)據(jù)庫(kù)操作系統(tǒng)的物理文件

    2024年02月15日
    瀏覽(22)
  • Linux系統(tǒng)中MySQL 數(shù)據(jù)庫(kù)的主從同步

    在主數(shù)據(jù)庫(kù)服務(wù)器上配置: 編輯主數(shù)據(jù)庫(kù)服務(wù)器的配置文件(my.cnf) : 打開(kāi) MySQL 配置文件,一般路徑為 /etc/my.cnf 或 /etc/mysql/my.cnf。 確保以下參數(shù)已啟用或配置正確: 注: 一定是[mysqld]代碼塊中 創(chuàng)建用于復(fù)制的用戶 : 登錄到 MySQL 控制臺(tái): mysql -u root -p 創(chuàng)建用于復(fù)制的用戶

    2024年03月23日
    瀏覽(19)
  • 在Linux環(huán)境中安裝配置Django與PostgreSQL數(shù)據(jù)庫(kù)

    Django是一款功能強(qiáng)大的Python Web框架,而PostgreSQL是一個(gè)開(kāi)源的高級(jí)關(guān)系型數(shù)據(jù)庫(kù)系統(tǒng)。本文將介紹在Linux環(huán)境中如何安裝和配置Django與PostgreSQL數(shù)據(jù)庫(kù),幫助您搭建一個(gè)完整的開(kāi)發(fā)環(huán)境。 第一步:安裝Django和PostgreSQL 安裝Python環(huán)境:首先確保您的Linux系統(tǒng)中已經(jīng)安裝了Python,可以

    2024年02月16日
    瀏覽(23)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包