考虑:
./mysqladmin -u root -p** '_redacted_'
输出(包括输入密码):
输入密码: Mysqladmin: connect to server at 'localhost' failed错误 '用户'root'@'localhost'(使用密码:YES)拒绝访问'
我该如何解决这个问题?
考虑:
./mysqladmin -u root -p** '_redacted_'
输出(包括输入密码):
输入密码: Mysqladmin: connect to server at 'localhost' failed错误 '用户'root'@'localhost'(使用密码:YES)拒绝访问'
我该如何解决这个问题?
当前回答
窗口:
cd \ampps\mysql\bin :
mysql.exe -u root -pmysql
mysql启动后(可以看到shell是这样的mysql>) 使用这个查询:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
请再次使用root访问
其他回答
我在这里的位置:
UBUNTU 21.04 PHP 5.6.40-57 MYSQL 5.7.37
我们来配置一下
nano /etc/mysql/mysql.conf.d/mysqld.cnf
在底部,写下这个
skip-grant-tables
重新加载它
service mysql restart
在我的Debian 10的情况下,错误
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
(好方法)解决了
sudo mysql -u root -p mysql
不好的方法:
mysql -u root -p mysql
修复macOS
Install MySQL from https://downloads.mysql.com/archives/community/ (8.x is the latest as on date, but ensure that the version is compatible with the macOS version) Give password for root (let <root-password> be the password) during installation (don't forget to remember the password!) Select Use Legacy Password Encryption option (that is what I had used and did not try for Use Strong Password Encryption option) Search and open MySQL.prefPane (use search tool) Select Configuration tab Click Select option of Configuration File Select /private/etc/my.cnf From terminal open a new or existing file with name /etc/my.cnf (vi /etc/my.cnf) add the following content: [mysqld] skip-grant-tables Restart mysqld as follows: ps aux | grep mysql kill -9 <pid1> <pid2> ... (grab pids of all MySQL related processes) mysqld gets restarted automatically Verify that the option is set by running the following from terminal: ps aux | grep mysql > mysql/bin/mysqld ... --defaults-file=/private/etc/my.cnf ... (output) Run the following command to connect (let mysql-<version>-macos<version>-x86_64 be the folder where MySQL is installed. To grab the actual folder, run ls /usr/local/ and copy the folder name): /usr/local/mysql-<version>-macos<version>-x86_64/bin/mysql -uroot -p<root-password>
我这样做是为了在OS x中MySQL的初始设置中设置我的根密码。
sudo sh -c 'echo /usr/local/mysql/bin > /etc/paths.d/mysql'
关闭终端并打开一个新终端。
在Linux中,可以使用以下方法设置根密码。
sudo /usr/local/mysql/support-files/mysql.server stop
sudo mysqld_safe --skip-grant-tables
(sudo mysqld_safe——skip-grant-tables:第一次对我不起作用。但在第二次尝试时,成功了。)
然后登录MySQL:
mysql -u root
FLUSH PRIVILEGES;
现在修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
重新启动MySQL:
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server start
解决方法:放弃!
听我说完。我花了整整两天的时间试图让MySQL工作,但没有任何效果,总是被权限错误卡住,没有一个是通过这个问题的答案解决的。我想,如果我继续下去,我会疯掉的。
由于没有耐心,我发送了安装SQLite的命令,只使用了450 KB,它从一开始就工作得很好。
如果你没有圣人的耐心,那就使用SQLite吧,这样可以为你节省大量的时间、精力、痛苦和存储空间。