我已经nginx
在运行 Raspbian Stretch 的 Raspberry Pi 上进行了安装,并Wordpress
在安装过程中运行了以下命令
sudo apt install mysql-server
sudo apt install php-mysql
我设置了 MariaDB 并设置了 WordPress 数据库
sudo mysql_secure_installation
sudo mysql -uroot -p
create database wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' IDENTIFIED BY 'redacted';
我已经完成了一些 WordPress 配置,并且想要备份我的 WordPress
我尝试安装phpmyadmin
( sudo apt install phpmyadmin
),但始终失败并出现错误ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
似乎没有选项可以输入 root@localhost 的密码
我试图询问MariaDB
这表明:-
MariaDB [(none)]> status
--------------
mysql Ver 15.1 Distrib 10.1.23-MariaDB, for debian-linux-gnueabihf (armv7l) using readline 5.2
Connection id: 104
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.1.23-MariaDB-9+deb9u1 Raspbian 9.0
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 18 hours 43 min 19 sec
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| wordpress |
+--------------------+
所以phpmyadmin
似乎没有创建数据库。
谁能帮我安装phpmyadmin
吗?
手动创建数据库 phpmyadmin 有帮助吗?
编辑
根据 @Kramer 的回答,这似乎是 Debian 的一个已知问题(我认为 Debian 软件包应该被检查)。
我现在已执行以下步骤(文件位置与建议的不同)
cd /usr/share/phpmyadmin/sql/
create database phpmyadmin;
mysql -u root -p < create_tables.sql
create database phpmyadmin;
grant all privileges on phpmyadmin.* to phpmyadmin@localhost identified by "redacted";
Grant USAGE ON mysql.* TO phpmyadmin@localhost;
GRANT SELECT ON mysql.db TO phpmyadmin@localhost;
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv) ON mysql.tables_priv TO phpmyadmin@localhost;
GRANT SELECT (Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv) ON mysql.user TO phpmyadmin@localhost;
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO phpmyadmin@localhost;
我nginx
通过添加以下内容/etc/nginx/sites-available/default
进行配置https://www.linuxbabe.com/linux-server/install-phpmyadmin-nginx-ubuntu-16-04
location /phpmyadmin {
root /usr/share/;
index index.php;
try_files $uri $uri/ =404;
location ~ ^/phpmyadmin/(doc|sql|setup)/ {
deny all;
}
location ~ /phpmyadmin/(.+\.php)$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
}
如图所示导航your-domain.com/phpmyadmin/
并登录phpmyadmin
php我的管理员。我以为成功了!,但是在导航到时Databases
我收到了以下错误:-
mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)
Connection for controluser as defined in your configuration failed.
似乎早期的尝试已创建/修改了文件,其中/etc/phpmyadmin/
尝试使用丢失的密码(根据安装日志)
Creating config file /etc/phpmyadmin/config-db.php with new version
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).
unable to connect to mysql server.
error encountered creating user:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
dbconfig-common: phpmyadmin configure: trying again.
Determining localhost credentials from /etc/mysql/debian.cnf: succeeded.
dbconfig-common: writing config to /etc/dbconfig-common/phpmyadmin.conf
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).
unable to connect to mysql server.
error encountered creating user:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
dbconfig-common: phpmyadmin configure: trying again.
Determining localhost credentials from /etc/mysql/debian.cnf: succeeded.
dbconfig-common: writing config to /etc/dbconfig-common/phpmyadmin.conf
Replacing config file /etc/dbconfig-common/phpmyadmin.conf with new version
Replacing config file /etc/phpmyadmin/config-db.php with new version
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).
unable to connect to mysql server.
error encountered creating user:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
答案1
首先,您收到的错误是因为某些脚本试图以 root 身份在没有密码的情况下执行 mysql:要么您是 root,要么您正在使用sudo
:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
假设您的 MySQL root 用户有密码,您需要按以下方式访问或与 MySQL CLI 交互:
mysql -u username -p
并且将在下面请求密码。
一个简单的(但不推荐的修复)是删除 root 的 MySQL 密码,执行整个安装,然后重新设置密码。这将使安装脚本顺利完成。
解决这个问题的正确方法将手动CREATE DATABASE
在安装脚本中找到该命令并使用mysql
上面的命令语法(使用用户名和密码)手动运行它。
创建配置存储
- 转到 phpMyAdmin 示例:
cd ${installation_path}/phpmyadmin/examples
- 导入示例:(
# mysql -u root -p < create_tables.sql
这将执行安装失败的脚本,并提示输入密码) - 重新启动 NGINX:
# systemctl restart nginx
来源http://howtolamp.com/lamp/phpmyadmin/4.2/installing#configuration-storage
另外, phpmyadmin 的文档规定了 Debian 的具体步骤,我猜这在 Raspbian 中是类似的:https://docs.phpmyadmin.net/en/latest/setup.html#linked-tables