MySQL 是一个开源的关系型数据库MySQL可以在 ​Linux、Unix 和Windows系统中运行,它可用于多种应用程序。

环境

FreeBSD 13-RELEASE

修改pkg源

需要先创建​​/usr/local/etc/pkg/repos​​目录,然后创建FreeBSD.conf配置文件,并将默认源关闭,然后添加国内软件源。

root@freebsd:~ # mkdir -p /usr/local/etc/pkg/repos
root@freebsd:~ # vi /usr/local/etc/pkg/repos/FreeBSD.conf

FreeBSD: { 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
}

在FreeBSD中安装MySQL数据库_mysql
更新pkg源:

root@freebsd:~ # pkg update -f
Updating 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.

在FreeBSD中安装MySQL数据库_oracle_02

安装MySQL数据库

搜索一下pkg源里面有哪些版本的mysql:

root@freebsd:~ # pkg search "^mysql"

在FreeBSD中安装MySQL数据库_mysql_03
下面安装mysql80版本:

root@freebsd:~ # pkg install -y mysql80-server mysql80-client

在FreeBSD中安装MySQL数据库_unix_04

运行MySQL

接下来你将运行下面的​​命令​​​,这会将 MySQL 服务添加到 ​​/etc/rc.conf​​配置文件中,并开机启动mysql。

root@freebsd:~ # sysrc mysql_enable=yes
mysql_enable: -> yes

在FreeBSD中安装MySQL数据库_mysql_05
启动mysql服务:

root@freebsd:~ # service mysql-server start
Starting mysql.

查看服务状态和mysql监听的端口:

root@freebsd:~ # service mysql-server status
mysql is running as pid 2194.
root@freebsd:~ # sockstat -4l
USER 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 *:*

在FreeBSD中安装MySQL数据库_unix_06

验证安装

要验证安装,您可以用 root 身份登录并使用以下​​命令​​检查数据库版本:

root@freebsd:~ # mysqladmin -u root -p version
Enter 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

在FreeBSD中安装MySQL数据库_mysql_07

总结

到目前MySQL 8 已安装并运行在 FreeBSD 13上了。

编辑:逄增宝,审核员:逄增宝

TRANSLATE with x English

​Arabic​

​Hebrew​

​Polish​

​Bulgarian​

​Hindi​

​Portuguese​

​Catalan​

​Hmong Daw​

​Romanian​

​Chinese Simplified​

​Hungarian​

​Russian​

​Chinese Traditional​

​Indonesian​

​Slovak​

​Czech​

​Italian​

​Slovenian​

​Danish​

​Japanese​

​Spanish​

​Dutch​

​Klingon​

​Swedish​

​English​

​Korean​

​Thai​

​Estonian​

​Latvian​

​Turkish​

​Finnish​

​Lithuanian​

​Ukrainian​

​French​

​Malay​

​Urdu​

​German​

​Maltese​

​Vietnamese​

​Greek​

​Norwegian​

​Welsh​

​Haitian Creole​

​Persian​

 

  TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: ​​Bing Webmaster Portal​

Back