阿里云centos删除mysql数据库_阿里云CentOS服务器中MySQL数据库的默认密码及修改...

服务器信息

系统镜像:CentOS 7.3

016f69addc29837cf08d26ec791a6a19.png

应用镜像:LAMP(Linux + Apache + MySQL + PHP),即mysql默认是安装好的。

d93fbf11b9fab50409bb3de8749613b5.png

命令

[root@deb ~]# # 登入系统,查看env.txt

[root@deb ~]# pwd

/root

[root@deb ~]# ls

env.txt sa_recovery.log

[root@deb ~]# cat env.txt

mysql_root_passwd:mysql的初始密码串

webroot_dir:/home/www/htdocs

apache_dir:/usr/local/apache

mysql_dir:/usr/local/mysql

php_dir:/usr/local/php56

[root@deb ~]# # 启动mysqld服务器

[root@deb ~]# /etc/rc.d/init.d/mysqld status

MySQL is not running [FAILED]

[root@deb ~]# /etc/rc.d/init.d/mysqld start

Starting MySQL. [ OK ]

[root@deb /]# # 登录mysql会话。

[root@deb /]# cd /usr/local/mysql/bin

[root@deb bin]# ./mysql -uroot -pmysql的初始密码串

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> # 查看mysql.user表中的账号信息

mysql> select Host, User, plugin, authentication_string, password_expired, password_last_changed, account_locked from mysql.user \G

*************************** 1. row ***************************

Host: localhost

User: root

plugin: mysql_native_password

authentication_string: *这里是一串用于认证的经过加密的字符串

password_expired: N

password_last_changed: 2018-11-02 23:03:05

account_locked: N

*************************** 2. row ***************************

Host: localhost

User: mysql.sys

plugin: mysql_native_password

authentication_string: *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE

password_expired: N

password_last_changed: 2017-08-08 12:07:24

account_locked: Y

2 rows in set (0.00 sec)

mysql> # 如果二者相同则结果为1;若不相同则返回0.

mysql> select (1 = 1), ('aa' = 'ab');

+---------+---------------+

| (1 = 1) | ('aa' = 'ab') |

+---------+---------------+

| 1 | 0 |

+---------+---------------+

1 row in set (0.00 sec)

mysql> # 证明:mysql中账户密码使用了password(str)对密码进行加密处理。

mysql> select password('mysql的初始密码串') = (select authentication_string from mysql.user where User = 'root');

+-----------------------------------------------------------------------------------------------+

| password('mysql的初始密码串') = (select authentication_string from mysql.user where User = 'root') |

+-----------------------------------------------------------------------------------------------+

| 1 |

+-----------------------------------------------------------------------------------------------+

1 row in set, 1 warning (0.00 sec)

mysql> # 修改密码(多种方法,不同工具|版本,操作也有细微的差别)

mysql> set password for 'root'@'localhost' = password('toor');

Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql>exit

Bye

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值