33.4 MySQL
最后更新于
# pkg info -D mysql97-server# service mysql-server enable# service mysql-server start# mysql -uroot -p
Enter password: # 此处直接按回车键
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.9 Source distribution
Copyright (c) 2000, 2026, 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>mysql> alter user 'root'@'localhost' identified by 'SecurePass123!'; -- 修改 root 用户的密码为 SecurePass123!,ALTER USER 直接修改授权表并立即生效
Query OK, 0 rows affected (0.01 sec)
mysql> 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.4.9 Source distribution
Copyright (c) 2000, 2026, 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> show databases; -- 显示当前 MySQL 实例中的所有数据库
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> quit; -- 退出 MySQL 命令行客户端
Bye/
└── usr/
└── local/
└── etc/
└── mysql/
├── my.cnf # MySQL 配置文件
└── my.cnf.sample # MySQL 配置文件示例
# cp /usr/local/etc/mysql/my.cnf.sample /usr/local/etc/mysql/my.cnfmysql_optfile="/abc/xyz.cnf"