记录一次奇葩的mariadb不能启动解决方法:
一、先是不能启动服务:
错误提示大概:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
1、关闭mysql数据库服务
systemctl stop mysqld
2、屏蔽权限
mysqld_safe --skip-grant-table
3、新开起一个终端输入:
mysql -u root mysql
delete from user where USER='';
FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
exit
二、重新启动系统后,启动过程
1、开启mysql数据库服务 systemctl start mysqld
2、登陆mysql, mysql -u root -p 提示ERROR 1698 (28000): Access denied for user 'root'@'localhost'
3、继续忽略权限:mysqld_safe --skip-grant-table
4、超级用户登陆mysql:sudo mysql -u root -p
输入密码:用户密码
输入密码:mysql root密码:
三、添加自己启动:
下次开机的时候记得启动服务,要不然会报错:
systemctl start mariadb
当然也可以开机自启动.但是我觉得自己启动比较舒服:
systemctl enable mariadb #自启动
systemctl disable mariadb #关闭自启动
1 MariaDB [(none)]> use mysql; 2 Reading table information for completion of table and column names 3 You can turn off this feature to get a quicker startup with -A 4 5 Database changed 6 MariaDB [mysql]> show tables; 7 +---------------------------+ 8 | Tables_in_mysql | 9 +---------------------------+ 10 | column_stats | 11 | columns_priv | 12 | db | 13 | event | 14 | func | 15 | general_log | 16 | global_priv | 17 | gtid_slave_pos | 18 | help_category | 19 | help_keyword | 20 | help_relation | 21 | help_topic | 22 | index_stats | 23 | innodb_index_stats | 24 | innodb_table_stats | 25 | plugin | 26 | proc | 27 | procs_priv | 28 | proxies_priv | 29 | roles_mapping | 30 | servers | 31 | slow_log | 32 | table_stats | 33 | tables_priv | 34 | time_zone | 35 | time_zone_leap_second | 36 | time_zone_name | 37 | time_zone_transition | 38 | time_zone_transition_type | 39 | transaction_registry | 40 | user | 41 +---------------------------+ 42 31 rows in set (0.001 sec) 43 44 MariaDB [mysql]> show user; 45 ERROR 1064 (42000): 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' at line 1 46 MariaDB [mysql]> create user 'gsc'@'%' identified by '设置的密码'; 47 Query OK, 0 rows affected (0.056 sec) 48 49 MariaDB [mysql]> grant select on *.* to 'gsc'@'%'; 50 Query OK, 0 rows affected (0.040 sec) 51 52 MariaDB [mysql]> flush privileges; 53 Query OK, 0 rows affected (0.001 sec) 54 55 MariaDB [mysql]> exit 56 Bye 57 [developRos WORKM]# exit 58 exit 59 nication ~ WORKM mysql -ugsc -p刚设置的密码 60 Welcome to the MariaDB monitor. Commands end with ; or \g. 61 Your MariaDB connection id is 21 62 Server version: 10.5.8-MariaDB Arch Linux 63 64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. 65 66 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 67 68 MariaDB [(none)]>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
2019-11-22 archlinux安装nvidia-1050ti闭源驱动教程,亲测
2019-11-22 键盘键码对照
2019-11-22 解决manjaro无法外接显示器
2017-11-22 AT&T汇编语言及其寻址方式
2017-11-22 汇编指令详解--as手册