MySQL/安装常见问题

来自康健生活

重置密码

查找 mysql 的配置文件。

[jian@kang /home/kangkk]$
whereis mysql
mysql: /usr/bin/mysql /usr/lib/mysql /etc/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

编辑配置文件,取消 root 用户的密码登录。

mysql.conf
...
# The following values assume you have at least 32M ram
[mysqld]
#
skip-grant-tables
#
# * Basic Settings
#
user            = mysql
...

重启 mysql 服务。

/home/kangkk
sudo systemctl restart mysql

进入 mysql。

/home/kangkk
mysql -uroot -p

重新设置密码。

mysql>
SET PASSWORD FOR 'root'@'localhost' = password('kangjian');

error

  • Access denied for user 'root'@'localhost'
重置密码
  • ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
 
FLUSH PRIVILEGES;
SET PASSWORD FOR 'root'@'localhost' = 'kangjian';
  • ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded
mysql>
UPDATE mysql.user
SET `plugin` = 'mysql_native_password'
WHERE `user` = 'root'
    AND `host` = 'localhost';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0
  • ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
密码设置的过于简单。