mysql - 检查与您的 MariaDB 服务器版本对应的手册以了解正确的语法

标签 mysql sql phpmyadmin mariadb

我正在尝试更改具有 10.1.13-MariaDB 的 PhPMyAdmin 的根密码 通过在 SQL 选项卡中键入以下内容并点击 Go 按钮:

ALTER USER
  'root'@'localhost' IDENTIFIED BY 'mypass'

我收到这个错误:

Error
SQL query:


ALTER USER
  'root'@'localhost' IDENTIFIED BY 'mypass'
MySQL said: Documentation

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USER 'root'@'localhost' IDENTIFIED BY 'mypass'' at line 1

我关注了this tutorial在 MySQL 网站上:

Create a text file containing the password-assignment statement on a single line. Replace the password with the password that you want to use.

MySQL 5.7.6 and later:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'

MySQL 5.7.5 and earlier:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');

以下是部分截图: enter image description here

enter image description here

最佳答案

这适用于 MariaDB:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass')

更改密码后,您将在 PhPMyAdmin 中看到以下内容: enter image description here其中说:mysql said: Cannot connect: invalid settings.

您应该打开 config.inc.php 文件并更改以下行:

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';

收件人:

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'newpass';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['Lang'] = '';

此文件默认位于 C:\xampp\phpMyAdmin 目录中。

关于mysql - 检查与您的 MariaDB 服务器版本对应的手册以了解正确的语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38231170/

相关文章:

php - 在没有 $request 的情况下执行 Laravel 验证

SQL Server 事件探查器显示正在调用但实际上并未执行的存储过程

c++ - 使用 mysql_fetch_row 后应用程序崩溃

mysql - 错误 : #1146 - Table 'information_schema.CHARACTER_SETS' doesn't exist

database - GAE 数据存储的前端 - 类似 phpMyAdmin 的 GAE

php - 如何正确比较 NodeJS 和 PHP 与 MySQL 的查询性能

php - 同一领域的多个喜欢

mysql - Amazon RDS 备份/快照实际上是如何工作的?

sql - 查询包含 JSON 对象数组的 jsonb 列

php - XAMPP - phpMyAdmin 错误 session_start() 权限被拒绝 (13)