mysql 多实例登录密码测试

最近在做mysql 多实例的时候,采用不同的方式登录mysql数据库,发现mysql -uroot -p -h 127.0.0.1 -P3308 ,登录时居然不要密码就可以登录,吓得我一身汗,经过检查终于找到原因记录下来,给小白们参考。

[[email protected] ~]# mysql -uroot -p -S /data/3308/mysql.sock

Enter password:          #需要输入密码

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

Your MySQL connection id is 23

Server version: 5.5.32-log Source distribution

Copyright (c) 2000, 2013, 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> select current_user();

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

| current_user() |

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

| [email protected] |

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

1 row in set (0.00 sec)

*******************************************************************

[[email protected] ~]# mysql -uroot -p -h 127.0.0.1 -P3308

Enter password:  #不需要输入密码,直接回车登录

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

Your MySQL connection id is 24

Server version: 5.5.32-log Source distribution

Copyright (c) 2000, 2013, 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> select  current_user();

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

| current_user() |

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

| [email protected] |

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

1 row in set (0.00 sec)

不要密码登录原因:

登录数据库查看密码

mysql> select user,host,password from mysql.user;

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

| user | host      | password                                  |

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

| root | localhost | *FE28814B4A8B3309DAC6ED7D3237ADED6DA1E515 |

| root | mysql     |                                           |

| root | 127.0.0.1 |                                           |

| root | ::1       |                                           |

|      | localhost |                                           |

|      | mysql     |                                           |

| tom  | %         | *71FF744436C7EA1B954F6276121DB5D2BF68FC07 |

| tom1 | %         | *36B46F2410B8A8E6E1DC6952C5C26929FDC07421 |

| tom2 | %         | *FEF6FE64F2588DC11E69F0DC5A704E231D1AAEFC |

| tom  | localhost | *71FF744436C7EA1B954F6276121DB5D2BF68FC07 |

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

10 rows in set (0.00 sec)

总结:第一种方式登录后,用户是 [email protected],第二种方式登录后,用户是[email protected] 查看数据库,发现[email protected]没有设置密码,所以使用第一种方式登录不需要输入密码。

时间: 2024-08-16 20:34:22

mysql 多实例登录密码测试的相关文章

MySQL单实例重置密码的两种方法

MySQL单实例重置密码的两种方法 在工作学习中,我们有时会忘记数据库的密码,下面是MySQL单实例密码重置的步骤. 说明: (1)[[email protected] ~]# cat /etc/redhat-release CentOS release 6.7 (Final) (2)[[email protected] ~]# mysql --version mysql  Ver 14.14 Distrib 5.7.13, for Linux (i686) using  EditLine wr

mysql单实例忘记密码如何登陆过程

mysql单实例root密码找回方法:a 停止mysql服务 [[email protected] data]# /etc/init.d/mysqld stop Shutting down MySQL.. SUCCESS! b 使用--skip-grant-tables启动mysql,忽略授权登录验证 [[email protected] data]# mysqld_safe --skip-grant-tables --user=mysql >/dev/null 2>&1 &

mysql用户修改登录密码及开启远程登录

一.修改用户登录密码: mysql> show databases;ERROR 1820 (HY000): You must SET PASSWORD before executing this statementmysql> quitBye[[email protected] ~]# mysqladmin -uroot -p password --修改用户密码Enter password: New password: Confirm new password: [[email protect

MySQL多实例忘记密码临时登陆

ss -antlup | grep 330     //说明有3306端口运行 数据库在运行 tcp    LISTEN     0      128                    *:3306                  *:*      users:(("mysqld",7557,12)) mysql -uroot -p -S /data/3306/mysql.sock //登录不了数据库,密码输入错误 killall mysqld     //杀死msyqld进程,

mysql 修改root登录密码

mysql -u root -p 然后回车,进入(等于用空密码进入) 2 use mysql; update user set password=password('123456') where user='root'; 这步就更新了密码 3 flush privileges; 刷新权限. 4 OK了,改好了

Mysql 多实例详细配置教程

8.14 Mysql 多实例 什么是多实例?就是一台机器上开启多个不同的服务端口,运行多个mysql服务进程,这些服务进程通过不同的socket监听不同的服务端口来提供各自的服务这些mysql实例共用一套mysql安装程序,使用不同(也可以相同)的my.cnf配置文,启动程序,数据库文件,在提供服务时,多实例mysql在逻辑上看来是各自独立, 优缺点:节约服务器资源并发高或慢查询时,整个实例消耗更多的系统资源,影响其它实例 8.14.1 配置mysql 建立数据目录mkdir -p /usr/l

登录多实例MySQL失败,修改密码临时解决,原因不明

昨天学习第11课"主从同步"的视频(L11-11-MySQL主从同步手把手实战操作详解w),再次遇到问题. [[email protected] ~]# mysql -uroot -p'oldboy3307' -S /data/3307/mysql.sock ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 上个月初学习安装多实例的时候,也遇到过这个报错.查看当时的日记

MySQL数据库登录密码管理

mysql数据库安装完成默认管理员的登录密码为空,因此可以无需输入密码直接登录数据库,这样是不安全的,以下文章简单介绍如何设置管理员登录数据库的密码和如何修改登录密码,以及忘记登录密码如何处理. 一.环境介绍 操作系统:CentOS 6.5 数据库版本:MySQL 5.5.32 主机名称:mysql-singleton 二.数据库密码管理  1.设置数据库初始密码  [[email protected] ~]# mysqladmin -uoldcat password "123456"

Mysql修改和破解登录密码(详)

Mysql修改或破解登录密码 一.重置MySQL管理密码 跳过授权表启动MySQL服务程序 这一步主要利用mysqld的 --skip-grant-tables选项,具体操作时可选择不同方式,但本质上是一样的.以下提供三种方式,任选其中一种都可以. 方式1(推荐),执行mysql脚本起服务,末尾加 --skip-grant-tables 参数: [[email protected] ~]# service mysql stop  服务关闭 [[email protected] ~]# servi