CentOS 8.x手动部署MySQL
问题描述:CentOS 8.x手动部署MySQL
步骤一:安装MySQL
问题描述:CentOS 8.x如何手动部署MySQL?
解决方案:
运行以下命令,安装MySQL。
1. sudo dnf -y install @mysql
2. 运行以下命令,查看MySQL版本信息。
mysql -V
5. 查看版本结果如下图所示。
步骤二:配置MySQL
1. 运行以下命令,启动并设置开机自启动MySQL服务。
2. sudo systemctl start mysqld
sudo systemctl enable mysqld
3. 运行以下命令,对MySQL进行安全性配置。
sudo mysql_secure_installation
a.根据提示信息,重置MySQL数据库root用户的密码。
Press y|Y for Yes, any other key for No: y #输入Y并回车开始相关配置。
There 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 file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 #选择密码验证策略强度,策略0表示低,1表示中,2表示高。建议您选择高强度的密码验证策略。
Please set the password for root here.
New password: #设置MySQL的新密码
Re-enter new password: #重复输入新的MySQL密码
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y ##输入Y确认使用已设置的密码。
b. 根据提示信息,删除匿名用户。
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 #输入Y删除MySQL默认的匿名用户。
Success.
c.禁止root账号远程登录。
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 #输入Y禁止root远程登录。
Success.
d. 删除test库以及对test库的访问权限。
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 #输入Y删除test库以及对test库的访问权限。
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
e.重新加载授权表。
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 #输入Y重新加载授权表。
Success.
All done!