我不知道我的MySQL根密码;我怎么才能知道呢?是否有存储此密码的文件?
我正在跟踪这个链接,但我在本地没有directadmin目录。
我不知道我的MySQL根密码;我怎么才能知道呢?是否有存储此密码的文件?
我正在跟踪这个链接,但我在本地没有directadmin目录。
当前回答
除非包管理器要求您在安装期间输入根密码,否则默认的根密码是空字符串。要连接到新安装的服务器,输入:
shell> mysql -u root --password=
mysql>
要更改密码,请返回unix shell并输入:
shell> mysqladmin -u root --password= password root
新密码为“root”。现在连接到服务器:
shell> mysql -u root --password=
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
哎呀,密码改了。使用新的根:
shell> mysql -u root --password=root
...
blah, blah, blah : mysql welcome banner
...
mysql>
宾果!做一些有趣的事情
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
莫里斯
其他回答
适用于Windows 10下的MySQL 5.5
您无法找到密码,因为它在表中是散列的,所以重置它是唯一的选择。
Lokesh kumar Chippada提供的通过.txt文件导入新密码脚本的解决方案对我不起作用。我发现命令提示符在启动导入后冻结了。
我在my.ini文件中添加了skip-grant-tables,就像tonycoupland在这篇SO帖子上的答案一样。
然后我就可以从命令行登录到mysql了
$ > mysql
然后在mysql中
mysql> FLUSH PRIVILEGES;
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
请参见mysql开发页面的“B.3.3.2.3重置Root密码:通用说明”。我现在已经从my.ini文件中删除了skip-grant-tables,并且我可以使用我创建的新密码作为根用户登录。
我用另一种方法解决了这个问题,这对一些人来说可能更简单。
我这样做是因为我尝试在安全模式下启动,但无法连接到错误: ERROR 2002 (HY000):无法通过socket '/var/run/mysqld/mysqld连接到本地MySQL服务器。袜子”(2)
我所做的就是以root用户正常连接:
$ sudo mysql -u root
然后我创建了一个新的超级用户:
mysql> grant all privileges on *.* to 'myuser'@'%' identified by 'mypassword' with grant option;
mysql> quit
然后以myuser身份登录
$ mysql -u myuser -p -h localhost
尝试更改密码没有给我任何错误,但对我没有任何帮助,所以我放弃并重新创建根用户
mysql> drop user 'root'@'localhost;
mysql> mysql> grant all privileges on *.* to 'root'@'localhost' identified by 'mypassword' with grant option;
根用户现在正在使用新密码
去phpMyAdmin > config.inc.php > $cfg['Servers'][$i]['password'] = ";
使用Debian / Ubuntu mysql包,可以使用Debian -sys- maintenance用户登录,该用户拥有所有的权限,密码保存在/etc/mysql/ Debian .cnf文件中
根据MySql版本的不同,该过程有所不同。按照您的版本所描述的步骤进行操作:
HINTS - Read before the instructions page for your version of MySql* In step 5: Instead of run CMD, create a shortcut on your desktop calling CDM.exe. Then right-click on the shortcut and select "Execute as Administrator". In step 6: Skip the first proposed version of the command and execute the second one, the one with the --defaults-file parameter Once you execute the command, if everything is ok, the CMD window remains open and the command of step 6 continues executing. Simply close the window (click 'x'), and then force close MySQl from the Task Manager. Delete the file with the SQL commands, and start again MySQL. The password must be changed now.
5.0 http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
5.1 http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html
…只需在链接中更改版本(5.5,5.6,5.7)