我不知道我的MySQL根密码;我怎么才能知道呢?是否有存储此密码的文件?
我正在跟踪这个链接,但我在本地没有directadmin目录。
我不知道我的MySQL根密码;我怎么才能知道呢?是否有存储此密码的文件?
我正在跟踪这个链接,但我在本地没有directadmin目录。
当前回答
这招对我很管用:
在终端类型上执行如下操作
$ sudo mysql -u root -p
Enter password://直接按Enter
mysql >
其他回答
mysql服务器安装后的默认密码是:mysql
有一件事绊倒了我在一个新的MySQL安装,并想知道为什么我不能得到默认密码工作,为什么甚至重置方法不起作用。 在Ubuntu 18上,MySQL服务器的最新版本在默认情况下根本不使用root用户的密码认证。这意味着不管你设置它为什么,它都不会让你使用它。它期望您从特权套接字登录。
mysql -u root -p
即使您使用了正确的密码,这也不起作用。
相反,你需要使用:
sudo mysql
这将适用于任何密码。 然后输入
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password you want to use';
然后登出,现在它将接受您的密码。
这里提供的答案似乎对我不起作用,事实证明,诀窍是: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password
(完整的答案在这里:在MySQL 5.7用" plugin: auth_socket "修改用户密码)
系统:
中佐的Linux 7 位于华盛顿市郊1414区
过程:
Open two shell sessions, logging in to one as the Linux root user and the other as a nonroot user with access to the mysql command. In your root session, stop the normal mysqld listener and start a listener which bypasses password authentication (note: this is a significant security risk as anyone with access to the mysql command may access your databases without a password. You may want to close active shell sessions and/or disable shell access before doing this): # systemctl stop mysqld # /usr/sbin/mysqld --skip-grant-tables -u mysql & In your nonroot session, log in to mysql and set the mysql root password: $ mysql mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass'); Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> quit; In your root session, kill the passwordless instance of mysqld and restore the normal mysqld listener to service: # kill %1 # systemctl start mysqld In your nonroot session, test the new root password you configured above: $ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. ... mysql>
除非包管理器要求您在安装期间输入根密码,否则默认的根密码是空字符串。要连接到新安装的服务器,输入:
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)
莫里斯