# pkg info -D mysql84-server
mysql84-server-8.4.3_1:
On install:
There is no initial password for first time use of MySQL. # 即无密码
首次使用 MySQL 时没有初始密码,即默认无密码
Keep in mind to reset it to a secure password.
请记得将其重置为安全密码
MySQL 8.4 has a default /usr/local/etc/mysql/my.cnf,
remember to replace it with your own
or set `mysql_optfile="$YOUR_CNF_FILE"` in rc.conf.
MySQL 8.4 有一个默认的 /usr/local/etc/mysql/my.cnf,
记得用你自己的文件替换它,
或者在 rc.conf 中设置 `mysql_optfile="$YOUR_CNF_FILE"`。
On upgrade:
As of MySQL 8.0.16, the MySQL server performs the upgrade tasks previously
handled by mysql_upgrade. Consequently, mysql_upgrade is unneeded and is
deprecated as of that version, and will be removed in a future MySQL version.
从 MySQL 8.0.16 开始,MySQL 服务器执行以前由 mysql_upgrade 处理的升级任务。
因此,mysql_upgrade 不再需要,并且从该版本开始被弃用,
将在未来的 MySQL 版本中移除。
Because mysql_upgrade no longer performs upgrade tasks,
it exits with status 0 unconditionally.
因为 mysql_upgrade 不再执行升级任务,
它无条件地以状态 0 退出。
# service mysql-server enable # 设置 MySQL 服务开机自启
# service mysql-server start # 启动 MySQL 服务
# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.0.27 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.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
root@localhost [(none)]> alter user 'root'@'localhost' identified by 'SecurePass123!'; -- 修改 root 用户在 localhost 的密码
Query OK, 0 rows affected (0.02 sec)
root@localhost [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
root@localhost [(none)]> quit; -- 退出 MySQL 命令行客户端
Bye
# mysql -uroot -p # 使用 root 用户登录 MySQL,并按提示输入密码
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 9
Server version: 8.0.27 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.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
root@localhost [(none)]> show databases; -- 显示当前 MySQL 实例中的所有数据库
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
/
└── usr/
├── local/
│ └── etc/
│ └── mysql/
│ ├── my.cnf # MySQL 配置文件
│ └── my.cnf.sample # MySQL 配置文件示例
└── ports/
└── databases/
├── mysql80-server/ # MySQL 8.0 Server 源码端口
└── mysql84-server/ # MySQL 8.4 Server 源码端口