mysql中使用過程中常見錯誤解決辦法收集

來源:互聯網
上載者:User

1、Mysql errono 1005 : 主外鍵不是完全一致 , 請檢查如下幾點:

      a、欄位是否存在
      b、類型是否一致(注意unsigned , powerdesign 產生問題)
      c、資料庫引擎是否一致
      d、字元編碼是否一致
      e、windows平台下注意修改lower_case_table_names = 0, windows本身不區分檔案大小寫,改為0之後就區分了可能造成找不到引用的表 

2、Mysql errono  121:  外鍵約束名稱重複

3、記錄 Mysql WorkBench 中單詞縮寫意義:
      PK: primary key (column is part of a pk)
      NN: not null (column is nullable)
      UQ: unique (column is part of a unique key)
      AI: auto increment (the column is auto incremented when rows are inserted)
      BIN: binary (if dt is a blob or similar, this indicates that is binary data, rather than text)
      UN: unsigned (for integer types, see docs: “10.2. Numeric Types”)
      ZF: zero fill (rather a display related flag, see docs: “10.2. Numeric Types”) 

4、mysql 使用權限設定
      //添加遠程主機訪問MYSQL root許可權
      insert into user(host,user,password) values('%','root',PASSWORD('root'));
      //root 許可權授權
      grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
      //更新使用權限設定
      flush privileges;

5、防火牆設定
      //開啟連接埠
      /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
      //儲存
      /etc/rc.d/init.d/iptables save
      //查看狀態
      /etc/init.d/iptables status

6、開機自動運行(實作類別似Windows服務)
      /sbin/chkconfig --level 2345 mysqld on
      /sbin/chkconfig --list
      結果如下:
      mysqld          0:off  1:off  2:on  3:on  4:on  5:on  6:off

7、linux下安裝了mysql,不能從其它機器訪問 帳號已經授權從任意主機進行訪問

vi /etc/sysconfig/iptables

在後面添加

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

service iptables restart

發現還是不行

最終發現記錄要添加在

-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT 這一條前面 再次重啟 OK

8、忘記mysql密碼

Microsoft Windows [版本 5.2.3790]

  (C) 著作權 1985-2003 Microsoft Corp.

  C:Documents and SettingsAdministrator>cd D:webwww.php100.comMysqlMySQL Se

  rver5.5bin

  C:Documents and SettingsAdministrator>d:

  D:webwww.php100.comMysqlMySQL Server5.5bin>mysql

  Welcome to the MySQL monitor. Commands end with ; or g.

  Your MySQL connection id is 1

  Server version: 5.5.10 MySQL Community Server (GPL)

  Copyright (c) 2000, 2010, 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> use mysql;

  Database changed

  mysql> update user set password=password("520") where user="root";

  Query OK, 1 row affected (0.00 sec)

  Rows matched: 1 Changed: 1 Warnings: 0

  mysql> flush privileges;

  Query OK, 0 rows affected (0.00 sec)

  mysql> q

  Bye

  D:webwww.php100.comMysqlMySQL Server5.5bin>

9、mysql 2003錯誤解決辦法

MySQL 伺服器資源緊張,導致無法串連
 
解決方案:
1、如果你是虛擬機器主機使用者(購買的空間),則聯絡空間商檢查 MySQL 是否正常啟動,並確認 MySQL 的配置資訊(是否為 localhost);
2、如果你是外掛式主控件使用者(擁有管理主機許可權),則按下面步驟檢查:
1)檢查是否啟動了 MySQL 服務。
Windows 主機的話,右鍵點擊我的電腦,單擊管理,在服務和應用程式中找到 MySQL 服務,看是否是已啟動的狀態。
如果出現"ERROR 2003: Can't connect to MySQL server on 'localhost' (10061)", 說明你的MySQL還沒有啟動。
解決辦法:
第一步
刪除c:windowns下面的my.ini
第二步
開啟c:mysqlbinwinmysqladmin.exe 輸入使用者名稱 和密碼
第三步 在dos下 輸入 mysqld-nt -remove 刪除服務
在接著輸入 mysqld-nt -install
第四步 輸入mysql 啟動成功

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.