Mariadb不显示mysql数据库问题排查
时间:2021-09-06
本文章向大家介绍Mariadb不显示mysql数据库问题排查,主要包括Mariadb不显示mysql数据库问题排查使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
现象
安装mariadb-server后,使用systemctl start mariadb启动mariadb,并使用mysql -uroot -p登录数据库。
执行show databases;命令查看数据库,发现只有information_schema和test数据库:
\# mysql -u root -p
Enter password:
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)
正常情况下查看数据库应该有:information_schema;mysql;performance_schema;test四个数据库。
但是到文件系统中查看/var/lib/mysql路径下是有mysql目录的,代表mysql数据库是存在的。
MariaDB [(none)]> use information_schema;
MariaDB [information_schema]> select * from USER_PRIVILEGES;
+----------------+---------------+----------------+--------------+
| GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
+----------------+---------------+----------------+--------------+
| ''@'localhost' | def | USAGE | NO |
+----------------+---------------+----------------+--------------+
1 row in set (0.00 sec)
MariaDB [information_schema]> grant all privileges on *.* to 'root'@'localhost';
ERROR 1045 (28000): Access denied for user ''@'localhost' (using password: NO)
解决方案
可能是没有权限导致:
在mariadb数据库的配置文件/etc/my.cnf的[mysqld]配置段中新增配置项skip-grant-tables,重启mariadb服务。再次登录mariadb查看数据库,可以看到所有的数据库都可见了:
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
尝试给root用户赋权可以查看所有的数据库,报错:
MariaDB [(none)]> grant all privileges on *.* to 'root'@'localhost';
ERROR 1290 (HY000): The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement #意思是使用了配置参数--skip-grant-tables后不可以修改权限。
可以通过执行flush privileges;解决以上报错,然后执行赋权操作并给root用户配置密码:
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> grant all privileges on *.* to 'root'@'localhost';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> SET password for 'root'@'localhost'=password('sql123');
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
退出数据库并将之前在/etc/my.cnf中的配置项#skip-grant-tables注释,然后重启mariadb,再次登录mariadb后就可以看到所有的数据库了。
学无止境,你说呢?
原文地址:https://www.cnblogs.com/moumouLiu/p/15233414.html
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解