Linux安装完MySQL重置密码启动

13 篇文章 0 订阅

[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2019-12-18 08:37:37 CST; 35s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 12484 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 12564 (mysqld)
Status: “Server is operational”
CGroup: /system.slice/mysqld.service
└─12564 /usr/sbin/mysqld

Dec 18 08:37:28 iZ2ze8bpfv23icsz3g2hp2Z systemd[1]: Starting MySQL Server…
Dec 18 08:37:37 iZ2ze8bpfv23icsz3g2hp2Z systemd[1]: Started MySQL Server.
[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2019-12-18 08:37:37 CST; 1min 8s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 12484 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 12564 (mysqld)
Status: “Server is operational”
CGroup: /system.slice/mysqld.service
└─12564 /usr/sbin/mysqld

Dec 18 08:37:28 iZ2ze8bpfv23icsz3g2hp2Z systemd[1]: Starting MySQL Server…
Dec 18 08:37:37 iZ2ze8bpfv23icsz3g2hp2Z systemd[1]: Started MySQL Server.
[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# mysql
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)
[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# mysql -u root
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)
[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# mysql -uroot
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)
[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# ps -ef | grep mysql
mysql 12564 1 0 08:37 ? 00:00:02 /usr/sbin/mysqld
root 12815 12264 0 08:41 pts/1 00:00:00 grep --color=auto mysql
[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# ps -ef | grep mysqld
mysql 12564 1 0 08:37 ? 00:00:02 /usr/sbin/mysqld
root 12819 12264 0 08:41 pts/1 00:00:00 grep --color=auto mysqld
[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
[root@iZ2ze8bpfv23icsz3g2hp2Z ~]# cd /var/log
[root@iZ2ze8bpfv23icsz3g2hp2Z log]# ls
anaconda cron-20191201 maillog-20191201 secure-20191124
audit cron-20191208 maillog-20191208 secure-20191201
boot.log cron-20191215 maillog-20191215 secure-20191208
boot.log-20191112 dmesg messages secure-20191215
boot.log-20191206 dmesg.old messages-20191124 spooler
boot.log-20191216 ecs_network_optimization.log messages-20191201 spooler-20191124
btmp firewalld messages-20191208 spooler-20191201
btmp-20191201 grubby messages-20191215 spooler-20191208
chrony grubby_prune_debug mysqld.log spooler-20191215
cloudinit-deploy.log journal ntpstats tallylog
cloud-init.log lastlog rhsm tuned
cron maillog sa wtmp
cron-20191124 maillog-20191124 secure yum.log
[root@iZ2ze8bpfv23icsz3g2hp2Z log]# grep ‘temporary password’ /var/log/mysqld.log
grep: password’: No such file or directory
[root@iZ2ze8bpfv23icsz3g2hp2Z log]# tail -f mysqld.log
2019-12-18T00:37:28.406306Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.18) initializing of server in progress as process 12511

这里不明白为啥 grep找这个玩意找不到 临时密码明明就在这里写着 为啥搜不到?

2019-12-18T00:37:33.050781Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: H?V3*(Gl;M*R
2019-12-18T00:37:35.693771Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 12564
2019-12-18T00:37:37.294049Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-12-18T00:37:37.322828Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: ‘8.0.18’ socket: ‘/var/lib/mysql/mysql.sock’ port: 3306 MySQL Community Server - GPL.
2019-12-18T00:37:37.408164Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: ‘/var/run/mysqld/mysqlx.sock’ bind-address: ‘::’ port: 33060
^C
[root@iZ2ze8bpfv23icsz3g2hp2Z log]# sudo mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 这里直接复制粘贴的临时密码

The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new password:
Sorry, passwords do not match.

New password:

Re-enter new password:
… Failed! Error: Your password does not satisfy the current policy requirements

New password:

Re-enter new password:
… Failed! Error: Your password does not satisfy the current policy requirements

New password:

Re-enter new password:
Sorry, passwords do not match.

New password:

Re-enter new password:
The ‘validate_password’ component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password:

Re-enter new password:

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
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
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) : n

… skipping.
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

  • 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) : y
Success.

All done!
[root@iZ2ze8bpfv23icsz3g2hp2Z log]#

All done! 看到这里就放心了

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值