mysql安装完成后的操作

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

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

2、使用yum批量安装

yum -y install ./mysql*.rpm

3、启动mysql服务

systemctl start mysqld

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

grep password /var/log/mysqld.log

2019-06-20T13:30:52.136848Z 1 [Note] A temporary password is generated for root@localhost: #

5、登录mysql,修改密码



修改mysql的配置文件,关闭密码审计策略
validate-password=off

重启mysqld服务器
systemctl restart mysqld

使用临时密码登录mysql
mysql -uroot -p'#

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

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

7、mysql安全优化向导

执行的命令:mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:
The 'validate_password' 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: 0  #安全审计的密码长度为0
Change the password for root ? ((Press y|Y for Yes, any other key for No) : no #是否需要修改密码

 ... 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) : yes  #是否需要移除匿名用户
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) : yes #是否禁止root用户远程登录
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) : yes #是否删除默认测试库
 - 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) : yes #是否立即刷新权限
Success.

All done!

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

在my.cnf配置文件中,增加如下参数:

skip-grant-tables

保存重启mysqld服务

systemctl restart mysqld

修改密码
update user set authentication_string=password('123456') where user='root';



 

你可能感兴趣的:(技术文档资料)