MySQL是一個開放原始碼的小型關聯式資料庫管理系統,目前MySQL被廣泛地應用在Internet上的中小型網站中。由於其體積小、速度快、整體擁有成本低,尤其是開放原始碼這一特點,許多中小型網站為了降低網站總體擁有成本而選擇了MySQL作為網站資料庫。
FreeBSD 13-RELEASE
需要先建立/usr/ local/etc/pkg/repos
目錄,然後建立FreeBSD.conf設定文件,並將預設來源關閉,然後新增國內軟體來源。
root@freebsd:~ # mkdir -p /usr/local/etc/pkg/reposroot@freebsd:~ # vi /usr/local/etc/pkg/repos/FreeBSD.confFreeBSD: { enabled: no } ustc: { url: "pkg+http://mirrors.ustc.edu.cn/freebsd-pkg//${ABI}/quarterly", mirror_type: "srv", signature_type: "fingerprints", fingerprints: "/usr/share/keys/pkg", enabled: yes }
更新pkg來源:
root@freebsd:~ # pkg update -fUpdating ustc repository catalogue... Fetching meta.txz: 100% 916 B 0.9kB/s 00:01 Fetching packagesite.txz: 100% 6 MiB 6.5MB/s 00:01 Processing entries: 100% ustc repository update completed. 30371 packages processed. All repositories are up to date.
搜尋pkg源裡面有哪些版本的mysql:
root@freebsd:~ # pkg search "^mysql"
下面安裝mysql80版本:
root@freebsd:~ # pkg install -y mysql80-server mysql80-client
接下來你將執行下面的指令,這會將MySQL 服務加入到/etc/rc.conf
設定檔中,並開機啟動mysql。
root@freebsd:~ # sysrc mysql_enable=yesmysql_enable: -> yes
啟動mysql服務:
root@freebsd:~ # service mysql-server startStarting mysql.
查看服務狀態和mysql監聽的連接埠:
root@freebsd:~ # service mysql-server statusmysql is running as pid 2194. root@freebsd:~ # sockstat -4lUSER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS mysql mysqld 2194 19 tcp46 *:33060 *:* mysql mysqld 2194 24 tcp4 127.0.0.1:3306 *:* root sshd 802 4 tcp4 *:22 *:* root sendmail 781 3 tcp4 127.0.0.1:25 *:* root syslogd 709 7 udp4 *:514 *:*
要驗證安裝,您可以用root 身分登入並使用下列命令檢查資料庫版本:
root@freebsd:~ # mysqladmin -u root -p versionEnter password: mysqladmin Ver 8.0.25 for FreeBSD13.0 on amd64 (Source distribution) Copyright (c) 2000, 2021, 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. Server version 8.0.25 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /tmp/mysql.sock Uptime: 4 min 16 sec Threads: 2 Questions: 6 Slow queries: 0 Opens: 138 Flush tables: 3 Open tables: 54 Queries per second avg: 0.023
以上是FreeBSD13中怎麼安裝MySQL資料庫的詳細內容。更多資訊請關注PHP中文網其他相關文章!