标签:erro 必须 change 不同 htm database match ogr denied
pi@raspberrypi:~ $ mysql -uroot
ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘
pi@raspberrypi:~ $
查看Mysql官方文档发现
Using Socket Pluggable Authentication
The socket plugin checks whether the socket user name (the operating system user name) matches the MySQL user name specified by the client program to the server. If the names do not match, the plugin checks whether the socket user name matches the name specified in the authentication_string column of the mysql.user system table row. If a match is found, the plugin permits the connection.(套接字插件检查套接字用户名(操作系统用户名)是否与客户端程序指定的MySQL用户名匹配到服务器。如果名称不匹配,插件将检查套接字用户名是否与mysql.user用户系统表行。如果找到匹配项,则插件允许连接。)
系统当前的用户是pi,要使用root账户必须使用sudo命令获得root身份再与Mysql连接。所以使用sudo mysql -uroot
可以进入Mysql命令行。
pi@raspberrypi:~ $ sudo service mysql restart
pi@raspberrypi:~ $ mysql -uroot
ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘
pi@raspberrypi:~ $ sudo mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 33
Server version: 10.0.28-MariaDB-2+b1 Raspbian testing-staging
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]>
长期以来,MySQL支持不同的身份验证插件,在此使用mysql_native_password传统的身份验证方法,不是很安全(它仅使用密码的哈希值),但是与较旧的驱动程序兼容。
sudo mysql -u root
进入MySQL命令行update user set plugin="mysql_native_password" where user="root";
要设置密码的话多加一条update user set password=PASSWORD("1989") where user="root";
flush privileges;
exit;
sudo service mysql restart
pi@raspberrypi:~ $ sudo service mysql restart
pi@raspberrypi:~ $ mysql -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 32
Server version: 10.0.28-MariaDB-2+b1 Raspbian testing-staging
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]>
没有设置密码直接使用mysql -u root
即可进入MySQL命令行。
sudo mysql -u root
进入MySQL命令行USE mysql
CREATE USER ‘YOU_SYSTEM_USER‘@‘localhost‘ IDENTIFIED BY ‘‘;
GRANT ALL PRIVILEGES ON *.* TO ‘YOUR_SYSTEM_USER‘@‘localhost‘;
UPDATE user SET plugin=‘auth_socket‘ WHERE User=‘YOUR_SYSTEM_USER‘;
FLUSH PRIVILEGES;
exit;
sudo service mysql restart
使用mysql -upi
直接进入MySQL命令行。
pi@raspberrypi:~ $ mysql -upi
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 34
Server version: 10.0.28-MariaDB-2+b1 Raspbian testing-staging
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]>
查看用户表
pi@raspberrypi:~ $ mysql -upi
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 34
Server version: 10.0.28-MariaDB-2+b1 Raspbian testing-staging
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> select user,host,plugin,password from user;
+------+-----------+-----------------------+----------+
| user | host | plugin | password |
+------+-----------+-----------------------+----------+
| root | localhost | mysql_native_password | |
| pi | localhost | unix_socket | |
+------+-----------+-----------------------+----------+
2 rows in set (0.00 sec)
MariaDB [mysql]>
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
标签:erro 必须 change 不同 htm database match ogr denied
原文地址:https://www.cnblogs.com/1328497946TS/p/13162531.html