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: #<glakty8TWB

密码:#<glakty8TWB

5、登录mysql,修改密码



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

重启mysqld服务器
systemctl restart mysqld

使用临时密码登录mysql
mysql -uroot -p'#<glakty8TWB' -A   #密码有特殊符号,使用单引号引起来

修改密码
alter user user() identified by '123456';

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';



 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值