手动搭建LNMP环境 安装MySQL 1. 依次执行以下命令,安装MySQL。 plaintext rpm Uvh yum y install mysqlcommunityserver 2. 依次执行以下命令,启动MySQL服务并设置开机自启动。 plaintext systemctl start mysqld systemctl enable mysqld 3. 执行以下命令,获取安装MySQL时自动设置的root用户密码。 plaintext grep 'temporary password' /var/log/mysqld.log 回显如下类似信息。 plaintext 20180829T07:27:37.541944Z 1 [Note] A temporary password is generated for root@localhost: 2YY?3uHUA?Ys 4. 执行以下命令,并按照回显提示信息进行操作,加固MySQL。 plaintext mysqlsecureinstallation Securing the MySQL server deployment. Enter password for user root: 输入上一步骤中获取的安装MySQL时自动设置的root用户密码 The existing password for the user account root has expired. Please set a new password. New password: 设置新的root用户密码 Reenter new password: 再次输入密码 The 'validatepassword' plugin is installed on the server. The subsequent steps will run with the existing configuration of the plugin. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press yY for Yes, any other key for No) : N 是否更改root用户密码,输入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 yY for Yes, any other key for No) : Y 是否删除匿名用户,输入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 yY for Yes, any other key for No) : Y