您的位置:首页 > 健康 > 美食 > 网站前端_天津建设教育培训中心_seo怎么搞_百度广告联盟官网

网站前端_天津建设教育培训中心_seo怎么搞_百度广告联盟官网

2025/4/18 17:29:32 来源:https://blog.csdn.net/qq_40914472/article/details/147247746  浏览:    关键词:网站前端_天津建设教育培训中心_seo怎么搞_百度广告联盟官网
网站前端_天津建设教育培训中心_seo怎么搞_百度广告联盟官网

1. 安装MySQL服务器​​

1. 更新仓库缓存

sudo dnf makecache

2. 安装MySQL

sudo dnf install mysql-server

2. 初始化数据库​

sudo mysqld --initialize --user=mysql

3. 启动数据库服务

# 启动服务
sudo systemctl start mysqld# 设置开机自启
sudo systemctl enable mysqld# 检查状态
sudo systemctl status mysqld

4. 获取初始临时密码​​

MySQL首次启动后会生成临时root密码:

[root@koji-builder local]# cat /var/log/mysql/mysqld.log 
2025-04-15T03:47:19.698504Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.26) initializing of server in progress as process 501966
2025-04-15T03:47:19.707644Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-04-15T03:47:20.097607Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-04-15T03:47:21.185380Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2025-04-15T03:47:21.185792Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2025-04-15T03:47:21.335996Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2025-04-15T03:47:24.352442Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.26) starting as process 502015
2025-04-15T03:47:24.360719Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-04-15T03:47:24.454276Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-04-15T03:47:24.663767Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2025-04-15T03:47:24.664110Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2025-04-15T03:47:24.666148Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2025-04-15T03:47:24.666287Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2025-04-15T03:47:24.683037Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/lib/mysql/mysqlx.sock
2025-04-15T03:47:24.683165Z 0 [System] [MY-010931] [Server] /usr/libexec/mysqld: ready for connections. Version: '8.0.26'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution.
2025-04-15T03:50:47.632895Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.26).
2025-04-15T03:50:48.933911Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.26)  Source distribution.
2025-04-15T03:51:01.921293Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.26) initializing of server in progress as process 502402
2025-04-15T03:51:01.937221Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-04-15T03:51:02.314323Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-04-15T03:51:03.280084Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2025-04-15T03:51:03.280364Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2025-04-15T03:51:03.328444Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: V8xP0pUmup?J

1.如果初始化后没有生成密码需要重新初始化

1.步骤 1: 停止 MySQL 服务​​

sudo systemctl stop mysqld

​​ 2: 清理残留数据(谨慎操作!)​​

# 确保是全新安装且无需保留数据
sudo rm -rf /var/lib/mysql/*

​​ 3: 重新初始化数据库​​

sudo mysqld --initialize --user=mysql
#此命令会生成新的临时密码并输出到日志文件。

4: 启动服务并查看日志​​

sudo systemctl start mysqld
sudo grep 'temporary password' /var/log/mysqld.log

5. 使用临时密码登录​

[root@koji-builder local]# mysql -u root -p'V8xP0pUmup?J'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.26Copyright (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.mysql>

6. 首次登录后强制修改密码​

修改 root 密码(需满足复杂度要求,如大小写字母、数字、符号)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'yuhua@24';
Query OK, 0 rows affected (0.00 sec)

7. 运行安全加固脚本​

[root@koji-builder local]# sudo mysql_secure_installation Securing the MySQL server deployment.Enter password for user root: VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?Press y|Y for Yes, any other key for No: yThere are three levels of password validation policy:LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.Estimated strength of the password: 50 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y- Dropping test database...
Success.- Removing privileges on test database...
Success.Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.All done! 
按提示操作:输入新设置的 root 密码。
移除匿名用户(选 Y)。
禁止远程 root 登录(选 Y)。
删除测试数据库(选 Y)。
刷新权限表(选 Y)。

8. 登录数据库

[root@koji-builder local]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.26 Source distributionCopyright (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.mysql>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com