mysql 故障案例 mysql故障案例

2021-10-17 19:32:22 字數 3294 閱讀 7692

##錯誤: error 1044 (42000): access denied for user 'root'@'%' to database 'dede'

mysql> create database dede;

error 2006 (hy000): mysql server has gone away

no connection. trying to reconnect...

connection id: 47299

current database: none

query ok, 1 row affected (0.00 sec)

mysql> grant all privileges on dede.* to 'dede'@'localhost' identified by 'dede123'; ##授權時執行失敗

error 2006 (hy000): mysql server has gone away

no connection. trying to reconnect...

connection id: 47302

current database: none

error 1044 (42000): access denied for user 'root'@'%' to database 'dede' ##拒絕訪問的使用者

解決:mysql> select grant_priv from mysql.user where host='localhost'; ##n代表沒有許可權

| grant_priv |

| n |

| n |

| n |

3 rows in set (0.00 sec)

mysql> select grant_priv from mysql.user where host='127.0.0.1';

| grant_priv |

| y |

1 row in set (0.00 sec)

mysql> update mysql.user set grant_priv='y' where host='localhost';

error 2006 (hy000): mysql server has gone away

no connection. trying to reconnect...

connection id: 47312

current database: none

query ok, 3 rows affected (0.01 sec)

rows matched: 3 changed: 3 warnings: 0

mysql> select grant_priv from mysql.user where host='localhost';

| grant_priv |

| y |

| y |

| y |

3 rows in set (0.00 sec)

mysql> flush privileges;

query ok, 0 rows affected (0.00 sec)

mysql> grant all privileges on dede.* to 'dede'@'localhost' identified by 'dede123';

error 1044 (42000): access denied for user 'root'@'%' to database 'dede'

mysql> show variables like 'read_only'

error 2006 (hy000): mysql server has gone away

no connection. trying to reconnect...

connection id: 47323

current database: none

| variable_name | value |

| read_only | off |

1 row in set (0.00 sec)

mysql> show global variables like 'max_allowed_packet'; ##檢視max_allowed_packet的值,預設是1mb

error 2006 (hy000): mysql server has gone away

no connection. trying to reconnect...

connection id: 47339

current database: none

| variable_name | value |

| max_allowed_packet | 1048576 |

1 row in set (0.00 sec)

mysql> set global max_allowed_packet=1024102416; ##臨時修改max_allowed_packet值為16mb,重啟失效

error 2006 (hy000): mysql server has gone away

no connection. trying to reconnect...

connection id: 47341

current database: none

query ok, 0 rows affected (0.00 sec)

mysql> show global variables like 'max_allowed_packet'; ##檢視.,臨時已生效

| variable_name | value |

| max_allowed_packet | 16777216 |

1 row in set (0.00 sec)

mysql> grant all privileges on dede.* to 'dede'@'localhost' identified by 'dede123'; ###grant授權使用者成功

error 2006 (hy000): mysql server has gone away

no connection. trying to reconnect...

connection id: 47347

current database: none

query ok, 0 rows affected (0.00 sec)

mysql> exit

bye###永久修改引數

[root@118 ~]# vim /etc/my.cnf

[mysqld]

max_allowed_packet = 16m

mysql 重啟生效

mysql故障案例 mysql故障案例

mysql create database dede error 2006 hy000 mysql server has gone away no connection.trying to reconnect.connection id 47299 current database none que...

mysql 安裝故障 MySQL安裝故障解決

mysql故障 root mysql m etc init.d mysqld restart starting mysql.error manager of pid file quit without updating file.root mysql m 可能一 啟動配置檔案 etc init.d ...

故障分析 MySQL 優化案例 字符集轉換

server version 5.7.24 log mysql community server gpl 開發聯絡我,說是開發庫上有一張檢視查詢速度很慢,9000 條資料要查 10s,要求我這邊協助排查優化。這個 sql 非常簡單,定義如下,其中就引用了view dataquality analys...