GVKun编程网logo

MYSQL中ERROR 1005 (HY000): Can''t create table 错误(mysql error 1006)

31

对于想了解MYSQL中ERROR1005(HY000):Can''tcreatetable错误的读者,本文将提供新的信息,我们将详细介绍mysqlerror1006,并且为您提供关于ERROR1(HY

对于想了解MYSQL中ERROR 1005 (HY000): Can''t create table 错误的读者,本文将提供新的信息,我们将详细介绍mysql error 1006,并且为您提供关于ERROR 1 (HY000): Can''t create/write to file ''/data、ERROR 1100 (HY000): Table ''api_category'' was not locked with、ERROR 2002 (HY000): Can't connect to local MySQL ser、ERROR 2002 (HY000): Can''t connect to local MySQL 错误的有价值信息。

本文目录一览:

MYSQL中ERROR 1005 (HY000): Can''t create table 错误(mysql error 1006)

MYSQL中ERROR 1005 (HY000): Can''t create table 错误(mysql error 1006)

今天创建一个MYSQL数据库时遇到的一个小问题:

create table booktype
(
   btid   int(5) unsigned zerofill auto_increment not null primary key,
   btname varchar(100) not null unique,
   btnote text
);

create table books
(
   bid int(5) unsigned zerofill auto_increment not null primary key,
   bname char(30) not null,
   isbn char(50) not null,
   author char(30) not null,
   press   text,
   summary text,
   bcount int not null default 0,
   btid   int,
   foreign key(btid) references booktype(btid) 
);

出现的报错:

ERROR 1005 (HY000): Can''t create table ''.\bookdata\books.frm'' (errno: 150)

主要问题是:

foreign key(btid) references booktype(btid) 中books表的 btid   是int和booktype表中的btid设置的关联字段类型不匹配,books表中btid改正成:btid   int(5) unsigned zerofill ,就不会报错了,创建表和修改表地时候常常一步小小就忘记了这个.

ERROR 1 (HY000): Can''t create/write to file ''/data

ERROR 1 (HY000): Can''t create/write to file ''/data

ERROR 1 (HY000): Can''t create/write to file ''/data

杨凯悦0人评论1552人阅读2018-02-24 11:38:49
 

使用非DBA用户进行load data 操作,发现报错。

MariaDB [temp_archive]> select * from t1 into outfile ''/data/test.sql'';

ERROR 1 (HY000): Can''t create/write to file ''/data/test.sql'' (Errcode: 13 "Permission denied")

 

提示报错。

报错原因权限不足。

分析:

   权限有系统权限和数据库权限。

/data 目录权限 chown -R mysql:mysql /data/

 

实验1:操作系统权限

创建hy用户,使用root账户操作,文件保存目录/data/:

useradd -u 1100 hy

password hy

su hy

[hy@XHY005116 /]$ mysql

MariaDB [(none)]> use test

Database changed

MariaDB [test]> select * from t111 into outfile ''/data/t111.sql'';

Query OK, 1 row affected (0.00 sec)

 

MariaDB [test]> create table t112 like t111;

Query OK, 0 rows affected (0.08 sec)

 

MariaDB [test]> load data infile ''/data/t111.sql'' into table t112;

Query OK, 1 row affected (0.02 sec)                  

Records: 1  Deleted: 0  Skipped: 0  Warnings: 0

 

  • 文件保存目录/

MariaDB [test]> select * from t111 into outfile ''/t111.sql'';

ERROR 1 (HY000): Can''t create/write to file ''/t111.sql'' (Errcode: 13 "Permission denied")

 

  • 报错:权限不足,此处可以分析出系统权限不足,导致报错。

 

实验2:

hy用户登录ya,ya账户读写权限,文件保存目录 /data/。

 

MariaDB [test]> select * from t100 into outfile ''/data/t100.sql'';

ERROR 1045 (28000): Access denied for user ''ya''@''192.168.%'' (using password: YES)

 

  • 使用root用户导出的文件,使用ya用户导入

MariaDB [test]> load data infile ''/data/t100.sql'' into table t101;

ERROR 1045 (28000): Access denied for user ''ya''@''192.168.%'' (using password: YES)

 

均报错:判断是数据库权限问题。

尝试授权file权限。

MariaDB [(none)]> grant file on *.* to ''ya''@''192.168.%'';

MariaDB [(none)]> flush privileges;

 

[hy@XHY005116 data]$ mysql -uya -p123456 -h192.168.5.116

MariaDB [test]> select * from t101 into outfile ''/data/t101.sql'';

 

MariaDB [test]> load data infile ''/data/t101.sql'' into table t102;

Query OK, 6 rows affected (0.02 sec)          


成功:

文件保存目录:/

MariaDB [test]> select * from t101 into outfile ''/t101.sql'';

ERROR 1 (HY000): Can''t create/write to file ''/t101.sql'' (Errcode: 13 "Permission denied

 

报错:权限问题。

 

  • 结合:上两个实验可以得出“(Errcode: 13 "Permission denied” 错误是和操作系统目录有关。

 

对应mysql的权限

blob.png

 

 

 

 

 

 

 

©著作权归作者所有:来自51CTO博客作者杨凯悦的原创作品,如需转载,请注明出处,否则将追究法律责任

ERROR 1100 (HY000): Table ''api_category'' was not locked with

ERROR 1100 (HY000): Table ''api_category'' was not locked with

mysql> show create table api_category;
ERROR 1100 (HY000): Table ''api_category'' was not locked with LOCK TABLES

字面意思:表“api_category”未用锁表锁定

两个命令解决:

LOCK TABLES `api_category` WRITE; #给表加锁

UNLOCK TABLES;  #给表解锁

 

本文同步分享在 博客“lxw1844912514”(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

ERROR 2002 (HY000): Can't connect to local MySQL ser

ERROR 2002 (HY000): Can't connect to local MySQL ser

输入 #mysql -u root -p ERROR 2002 (HY000):Can''t connect to local MySQL server 随即上网找寻答案 根据大家提供的方法我逐一尝试 方案1. 1.#ps -A|grep mysql 显示类: 1829 ? 00:00:00 mysqld_safe 1876 ? 00:00:31 mysqld 2.#kill -9 1829 3.#kill -9 1

 

输入

#mysql -u root -p

ERROR 2002 (HY000):Can''t connect to local MySQL server

随即上网找寻答案

根据大家提供的方法我逐一尝试

方案1.

1.#ps -A|grep mysql

   显示类似:

  1829 ?        00:00:00 mysqld_safe
   1876 ?        00:00:31 mysqld

  2.#kill -9 1829

  3.#kill -9 1876

  4.#/etc/init.d/mysql restart

  5.#mysql-u root -p

   他的麻烦解决了,我的还没解决!

继续找

方案2

先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动. 另外看看是不是权限问题. ------------------------------------------------------------------------------------ [root@localhost beinan]#chown -R mysql:mysql /var/lib/mysql [root@localhost beinan]# /etc/init.d/mysqld start 启动 MySQL: [ 确定 ] [root@localhost lib]# mysqladmin -uroot password ''123456'' [root@localhost lib]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 3 to server version: 4.1.11 Type ''help;'' or ''/h'' for help. Type ''/c'' to clear the buffe 他的也解决了,我的麻烦还在继续,依然继续寻找

方案3

问题解决了,竟然是max_connections=1000 他说太多了,然后改成500也说多,无奈删之问题解决了。

还是不行

方案4

   

     /var/lib/mysql 所有文件权限 改成mysql.mysql

    

     不行不行

方案5

     摘要:解决不能通过mysql.sock连接MySQL问题 这个问题主要提示是,不能通过 ''/tmp/mysql.sock''连到服务器,而php标准配置正是用过''/tmp/mysql.sock'',但是一些mysql安装方法mysql.sock放在/var/lib/mysql.sock或者其他的什么地方,你可以通过修改/etc/my.cnf文件来修正它,打开文件,可以看到如下的东东:

  [mysqld]
  socket=/var/lib/mysql.sock
  改一下就好了,但也会引起其他的问题,如mysql程序连不上了,再加一点:
  [mysql]
  socket=/tmp/mysql.sock
  或者还可以通过修改php.ini中的配置来使php用其他的mysql.sock来连,这个大家自己去找找
  
  或者用这样的方法:
  ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

成功了,就是这样ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

 

http://blog.csdn.net/lmss82/article/details/4414178

ERROR 2002 (HY000): Can''t connect to local MySQL 错误

ERROR 2002 (HY000): Can''t connect to local MySQL 错误

ERROR 2002 (HY000): Can''t connect to local MySQL server through socket ''/var/run/mysqld/mysqld.sock'' (2)

最后发现在 my.cnf 配置文件中,有一行绑定 IP 的没有修改,还是原来的 IP,把它修改成当前 mysql 服务器的 IP,重启服务(sudo service mysql restart),即可,用回环地址(127.0.0.1)和 localhost,远程的客户端便访问不到,不知为什么。比如我的是私网地址 192.168.31.245,直接 bind-address = 192.168.31.245


############################################################################

这个并不好使?

http://stackoverflow.com/questions/5376427/cant-connect-to-local-mysql-server-through-socket-var-mysql-mysql-sock-38

34        down vote

I got the following error

ERROR 2002 (HY000): Can''t connect to local MySQL server through socket ''/var/run/mysqld/mysqld.sock'' (111)

Tried several ways and finally solved it through the following way

sudo gksu gedit /etc/mysql/my.cnf

modified

#bind-address       = 127.0.0.1

to

bind-address        = localhost

and restarted

sudo /etc/init.d/mysql restart

it worked



























今天关于MYSQL中ERROR 1005 (HY000): Can''t create table 错误mysql error 1006的分享就到这里,希望大家有所收获,若想了解更多关于ERROR 1 (HY000): Can''t create/write to file ''/data、ERROR 1100 (HY000): Table ''api_category'' was not locked with、ERROR 2002 (HY000): Can't connect to local MySQL ser、ERROR 2002 (HY000): Can''t connect to local MySQL 错误等相关知识,可以在本站进行查询。

本文标签: