赞
踩
cd /usr/local/src/
wget https://dev.mysql.com/get/mysql-apt-config_0.8.24-1_all.deb
dpkg -i mysql-apt-config_0.8.24-1_all.deb
apt update
apt install mysql-server
mysql -uroot
CREATE USER 'root'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
FLUSH PRIVILEGES;
ALTER USER 'root'@'%' IDENTIFIED BY '123456';
以mysql -uroot
还是能够登录?
问题可能是auth_socket认证引起的,执行以下命令查看是否为
mysql> select plugin,authentication_string from mysql.user where user = 'root';
+-----------------------+-------------------------------------------+
| plugin | authentication_string |
+-----------------------+-------------------------------------------+
| auth_socket | |
+-----------------------+-------------------------------------------+
2 rows in set (0.00 sec)
mysql>
这个时候只需要修改认证方式为mysql_native_password
即可
ysql> alter user 'root'@'localhost' identified with mysql_native_password by '123456'; Query OK, 0 rows affected (0.01 sec) mysql> select plugin,authentication_string from mysql.user where user = 'root' -> ; +-----------------------+-------------------------------------------+ | plugin | authentication_string | +-----------------------+-------------------------------------------+ | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | +-----------------------+-------------------------------------------+ 1 row in set (0.00 sec) mysql> exit Bye root@VM-0-5-ubuntu:/home/lighthouse# mysql -uroot ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) root@VM-0-5-ubuntu:/home/lighthouse# mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 36 Server version: 8.0.31 MySQL Community Server - GPL Copyright (c) 2000, 2022, Oracle and/or its affiliates. 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>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。