mysql安装完成后的操作

灰太狼 2022-01-10 02:37 355阅读 0赞

1、下载mysqltar包之后,使用ftp工具上传到服务器,解压缩

  1. tar xf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar

2、使用yum批量安装

  1. yum -y install ./mysql*.rpm

3、启动mysql服务

  1. systemctl start mysqld

4、通过过滤mysql的日志文件,找出临时密码

  1. grep password /var/log/mysqld.log
  2. 2019-06-20T13:30:52.136848Z 1 [Note] A temporary password is generated for root@localhost: #<glakty8TWB
  3. 密码:#<glakty8TWB

5、登录mysql,修改密码

  1. 修改mysql的配置文件,关闭密码审计策略
  2. validate-password=off
  3. 重启mysqld服务器
  4. systemctl restart mysqld
  5. 使用临时密码登录mysql
  6. mysql -uroot -p'#<glakty8TWB' -A #密码有特殊符号,使用单引号引起来
  7. 修改密码
  8. alter user user() identified by '123456';

6、修改数据库的默认字符集

  1. 修改配置文件my.cnf
  2. character_set_server = utf8

7、mysql安全优化向导

  1. 执行的命令:mysql_secure_installation
  2. Securing the MySQL server deployment.
  3. Enter password for user root:
  4. The 'validate_password' plugin is installed on the server.
  5. The subsequent steps will run with the existing configuration
  6. of the plugin.
  7. Using existing password for root.
  8. Estimated strength of the password: 0 #安全审计的密码长度为0
  9. Change the password for root ? ((Press y|Y for Yes, any other key for No) : no #是否需要修改密码
  10. ... skipping.
  11. By default, a MySQL installation has an anonymous user,
  12. allowing anyone to log into MySQL without having to have
  13. a user account created for them. This is intended only for
  14. testing, and to make the installation go a bit smoother.
  15. You should remove them before moving into a production
  16. environment.
  17. Remove anonymous users? (Press y|Y for Yes, any other key for No) : yes #是否需要移除匿名用户
  18. Success.
  19. Normally, root should only be allowed to connect from
  20. 'localhost'. This ensures that someone cannot guess at
  21. the root password from the network.
  22. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : yes #是否禁止root用户远程登录
  23. Success.
  24. By default, MySQL comes with a database named 'test' that
  25. anyone can access. This is also intended only for testing,
  26. and should be removed before moving into a production
  27. environment.
  28. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : yes #是否删除默认测试库
  29. - Dropping test database...
  30. Success.
  31. - Removing privileges on test database...
  32. Success.
  33. Reloading the privilege tables will ensure that all changes
  34. made so far will take effect immediately.
  35. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : yes #是否立即刷新权限
  36. Success.
  37. All done!

8、mysql5.7版本跳过密码验证,修改密码

  1. my.cnf配置文件中,增加如下参数:
  2. skip-grant-tables
  3. 保存重启mysqld服务
  4. systemctl restart mysqld
  5. 修改密码
  6. update user set authentication_string=password('123456') where user='root';

发表评论

表情:
评论列表 (有 0 条评论,355人围观)

还没有评论,来说两句吧...

相关阅读