msyql本地登录不需要密码的方法

msyql本地登录不需要密码的方法,第1张

1.在需要进行mysq登录 *** 作的用户下建立如下的文件:

vi ~/.my.cnf

将下边的内容放入上方的文件当中

[client]

host='localhost'

#登录的用户名

user='system'

#用户的密码

password='guan'

2.编辑完成的文件如下图:

[root@master2 ~]# cat ~/.my.cnf

[client]

host='localhost'

#登录的用户名

user='system'

#用户的密码

password='guan'

3.测试

保存后,再登录mysql的时候,只需要输入mysql们不需要加后面的用户名和密码

[root@master2 ~]# mysql   #后边没有跟用户名和密码

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

Your MySQL connection id is 4

Server version: 5.6.14-log MySQL Community Server (GPL)

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>  ##可以看到我们已经登陆成功

1、以管理员的身份打开cmd,然后跳过权限启动mysql,命令:xxx --skip-grant-tables 前面是mysql配置文件的位置,然后回车。

2、新打开个cmd窗口,进入到mysql配置文件目录bin下,然后输入 mysql -uroot -p 再回车,这步是以空密码进入mysql。

3、空密码进入mysql后,如果前面都设置正确的话,这步显示的界面是Welcome to the MariaDB monitor。

4、然后可以show database; 查看当前的数据库,回车后会列举出当前数据库的列表。

5、然后执行命令:update user set password=password('新密码') where user='root'并回车,其中括号中的就是将要设置的新密码。

6、执行完后会提示你 Query OK,表示执行成功了,再用新密码登录就可以了。

新安装的mysql可以使用默认用户名和密码。

1、新安装的MySQL数据库账号默认是root,密码为空。key直接在命令行上输入mysql就可以登录了 ;

2、建立新用户

进入命令行模式,输入:

mysql -u root -p

mysql>use mysql

mysql>UPDATE user SET password=PASSWORD("new password") WHERE user='username'

mysql>FLUSH PRIVILEGES

mysql>quit

这样就建立了username 账号密码new password


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6271219.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-19
下一篇 2023-03-19

发表评论

登录后才能评论

评论列表(0条)

保存