mysql登陆报错mysql: unknown variable 'basedir=
发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,使用mysql登陆数据库报错[root@localhost ~]# mysql -uroot -pmysql: unknown variable 'basedir=/usr'报错原因:配置文件里面的格
千家信息网最后更新 2026年11月03日mysql登陆报错mysql: unknown variable 'basedir=使用mysql登陆数据库报错
[root@localhost ~]# mysql -uroot -p
mysql: unknown variable 'basedir=/usr'
报错原因:
配置文件里面的格式有误,[mysqld]写成了[mysql]
[root@localhost step]# cat /etc/my.cnf
[mysql]
basedir = /usr
datadir = /var/lib/mysql
log-error = /var/lib/mysql/localhost.localdomain.err
pid-file = /var/lib/mysql/localhost.localdomain.pid
log-bin=/var/lib/mysql/mysqld-bin
binlog_format=row
binlog-do-db=dmcdbTEST
解决方法:
将[mysql]改为[mysqld]
[root@localhost step]# cat /etc/my.cnf
[mysqld]
basedir = /usr
datadir = /var/lib/mysql
log-error = /var/lib/mysql/localhost.localdomain.err
pid-file = /var/lib/mysql/localhost.localdomain.pid
log-bin=/var/lib/mysql/mysqld-bin
binlog_format=row
binlog-do-db=dmcdbTEST
之后重启数据库
[root@localhost mysql]# mysqladmin -uroot -p shutdown
[root@localhost mysql]# mysqld_safe --defaults-file=/etc/my.cnf &
数据库可以正常连接
[root@localhost ~]# mysql -uroot -p
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.21-70.1 Percona Server (GPL), Release 70.1, Revision 698
Copyright (c) 2009-2014 Percona LLC and/or its affiliates
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show global variables like '%double%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| innodb_doublewrite | ON |
+--------------------+-------+
1 row in set (0.00 sec)
[root@localhost ~]# mysql -uroot -p
mysql: unknown variable 'basedir=/usr'
报错原因:
配置文件里面的格式有误,[mysqld]写成了[mysql]
[root@localhost step]# cat /etc/my.cnf
[mysql]
basedir = /usr
datadir = /var/lib/mysql
log-error = /var/lib/mysql/localhost.localdomain.err
pid-file = /var/lib/mysql/localhost.localdomain.pid
log-bin=/var/lib/mysql/mysqld-bin
binlog_format=row
binlog-do-db=dmcdbTEST
解决方法:
将[mysql]改为[mysqld]
[root@localhost step]# cat /etc/my.cnf
[mysqld]
basedir = /usr
datadir = /var/lib/mysql
log-error = /var/lib/mysql/localhost.localdomain.err
pid-file = /var/lib/mysql/localhost.localdomain.pid
log-bin=/var/lib/mysql/mysqld-bin
binlog_format=row
binlog-do-db=dmcdbTEST
之后重启数据库
[root@localhost mysql]# mysqladmin -uroot -p shutdown
[root@localhost mysql]# mysqld_safe --defaults-file=/etc/my.cnf &
数据库可以正常连接
[root@localhost ~]# mysql -uroot -p
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.21-70.1 Percona Server (GPL), Release 70.1, Revision 698
Copyright (c) 2009-2014 Percona LLC and/or its affiliates
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show global variables like '%double%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| innodb_doublewrite | ON |
+--------------------+-------+
1 row in set (0.00 sec)
数据
数据库
登陆
原因
文件
方法
格式
配置
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
广东万易互联网科技有限公司惠州分公司
广州万易互联网科技有限公司
深圳恒合互联网络科技有限公司
工业互联网科技新基建
互联网医疗科技
互联网科技媒体
万达互联网科技
互联网科技美容
太原新华互联网科技学校怎么样
现代科技和互联网有关系吗
字节跳动和互联网科技
团飞科技与伯堂互联网服务平台
互联网时代科技改变生活
世界互联网科技公司市值排名
科技类公司包括互联网吗
浙南科技城互联网大厦建设工程
互联网科技大赛获奖感言
互联网风格科技公司名称
福仕德教育科技互联网
互联网对科技影响
为想互联网科技
凡科互联网科技
郑州华宇互联网科技
互联网科技咨询
互联网科技生活的内容
北京大学互联网科技怎么样
互联网经济与金融科技
上海宁丞科技互联网
洛阳昕诺飞互联网科技有限公司
区块链结合互联网科技