国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

MySQL 連接不上的常見問題

這篇具有很好參考價值的文章主要介紹了MySQL 連接不上的常見問題。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

1.windows的ip問題
?? ?ping Linux服務(wù)器的ip,檢查網(wǎng)絡(luò)是否通暢
?? ?Linux服務(wù)器的網(wǎng)絡(luò)問題
2.連接的用戶是否有授權(quán)
????grant?
3.linux里的防火墻是否開啟
????iptables -L
????service firewalld stop
4.檢查下mysql服務(wù)是否開啟
????ps aux|grep mysqld
5.檢查下端口號是否修改
????netstat -anlput|grep mysqld
6.云服務(wù)器的安全組


1.windows里檢查,打開cmd,ping Linux服務(wù)器ip,檢查網(wǎng)絡(luò)。

mysql連不上,MySQL,mysql,數(shù)據(jù)庫,linux

?Linux服務(wù)器檢查,ping百度、windows機器等,檢查網(wǎng)絡(luò)。

[root@mysql mysql]# ping www.baidu.com
PING www.a.shifen.com (112.80.248.75) 56(84) bytes of data.
64 bytes from 112.80.248.75 (112.80.248.75): icmp_seq=1 ttl=128 time=62.2 ms
64 bytes from 112.80.248.75 (112.80.248.75): icmp_seq=2 ttl=128 time=72.0 ms
64 bytes from 112.80.248.75 (112.80.248.75): icmp_seq=3 ttl=128 time=26.5 ms
64 bytes from 112.80.248.75 (112.80.248.75): icmp_seq=4 ttl=128 time=24.9 ms
64 bytes from 112.80.248.75 (112.80.248.75): icmp_seq=5 ttl=128 time=25.9 ms
64 bytes from 112.80.248.75 (112.80.248.75): icmp_seq=6 ttl=128 time=31.4 ms


[root@mysql mysql]# ping 192.168.1.117
PING 192.168.1.117 (192.168.1.117) 56(84) bytes of data.
64 bytes from 192.168.1.117: icmp_seq=1 ttl=128 time=0.658 ms
64 bytes from 192.168.1.117: icmp_seq=2 ttl=128 time=1.71 ms
64 bytes from 192.168.1.117: icmp_seq=3 ttl=128 time=1.84 ms
64 bytes from 192.168.1.117: icmp_seq=4 ttl=128 time=0.708 ms

文件socket:實現(xiàn)一臺電腦里的不同進程之間通信的文件
網(wǎng)絡(luò)socket:ip+端口(?實現(xiàn)跨宿主機之間通信)

[root@mysql etc]# cat my.cnf
[mysqld_safe]

[client]
#socket=/data/mysql/mysql.sock

[mysqld]
socket=/data/mysql/mysql.sock
port = 3306
open_files_limit = 8192
innodb_buffer_pool_size = 512M
character-set-server=utf8

[mysql]
auto-rehash
prompt=\u@\d \R:\m ?mysql>

[root@mysql ~]# mysql -uroot -p123456sc
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

# 使用文件socket
[root@mysql ~]# mysql -uroot -p123456sc? -S /data/mysql/mysql.sock
mysql: [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 3
Server version: 5.7.41 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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.

root@(none) 12:12 ?mysql>

[root@mysql ~]# mysql -h 192.168.102.139 -P3306 -uroot -p'your?passwd'
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1130 (HY000): Host 'mysql' is not allowed to connect to this MySQL server

創(chuàng)建一個用戶并且授權(quán)

# 連接MySQL
[root@mysql ~]# mysql -uroot -p'your?passwd'
mysql: [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 7
Server version: 5.7.41 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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.

# 創(chuàng)建一個用戶
root@(none) 18:47 ?mysql>create user 'hanwl'@'%' identified by '123456sc';
Query OK, 0 rows affected (0.00 sec)

# 給這個用戶授權(quán)
root@(none) 18:48 ?mysql>grant all on *.* to 'hanwl'@'%';
Query OK, 0 rows affected (0.00 sec)

'hanwl'@'%'
% 是通配符,代表任意的字符串

grant 是mysql里的授權(quán)命令
all 代表授予所有的權(quán)限 select、insert、update、delete等
on *.* 第1個* 代表庫,第2個*代表庫
to 'hanwl'@'%' 給具體的用戶

[root@mysql ~]# mysql -h 192.168.102.139 -P3306 -uhanwl -p123456sc
mysql: [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 9
Server version: 5.7.41 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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.

hanwl@(none) 18:49 ?mysql>

添加一條防火墻規(guī)則

[root@mysql ~]# iptables -A INPUT -p tcp --dport 3306 -j DROP
[root@mysql ~]# iptables -L -n -v
Chain INPUT (policy ACCEPT 77 packets, 4484 bytes)
?pkts bytes target ? ? prot opt in ? ? out ? ? source ? ? ? ? ? ? ? destination ? ? ? ??
? ? 7 ? 700 DROP ? ? ? tcp ?-- ?* ? ? ?* ? ? ? 0.0.0.0/0 ? ? ? ? ? ?0.0.0.0/0 ? ? ? ? ? ?tcp dpt:3306

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
?pkts bytes target ? ? prot opt in ? ? out ? ? source ? ? ? ? ? ? ? destination ? ? ? ??

Chain OUTPUT (policy ACCEPT 48 packets, 3792 bytes)
?pkts bytes target ? ? prot opt in ? ? out ? ? source ? ? ? ? ? ? ? destination ? ? ? ??

[root@mysql ~]# mysql -h 192.168.102.139 -P3306 -uhanwl -p123456sc
mysql: [Warning] Using a password on the command line interface can be insecure.

去除剛添加的防火墻規(guī)則

[root@mysql ~]# iptables -D INPUT -p tcp --dport 3306 -j DROP

[root@mysql ~]# mysql -h 192.168.102.139 -P3306 -uhanwl -p123456sc
mysql: [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 10
Server version: 5.7.41 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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.

hanwl@(none) 18:53 ?mysql>

mysql服務(wù)是否開啟

看進程

[root@mysql etc]# ps aux|grep mysqld
root ? ? ?10231 ?0.0 ?0.0 ?11824 ?1600 ? ? ? ? ?S ? ?12:41 ? 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/mysql.pid
mysql ? ? 10387 ?0.1 13.2 1763324 246660 ? ? ? ?Sl ? 12:41 ? 0:23 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=mysql.err --open-files-limit=8192 --pid-file=/data/mysql/mysql.pid --socket=/data/mysql/mysql.sock --port=3306
root ? ? ?10598 ?0.0 ?0.0 112832 ? 988 pts/2 ? ?S+ ? 16:31 ? 0:00 grep --color=auto mysqld

看端口

[root@mysql etc]# netstat -anlput|grep mysqld
tcp6 ? ? ? 0 ? ? ?0 :::3306 ? ? ? ? ? ? ? ? :::* ? ? ? ? ? ? ? ? ? ?LISTEN ? ? ?10387/mysqld ? ? ? ?
tcp6 ? ? ? 0 ? ? ?0 192.168.102.139:3306 ? ?192.168.102.1:60719 ? ? ESTABLISHED 10387/mysqld ?

直接進入MySQL

[root@mysql ~]# mysql -uroot -p'Sanchuang1234#'
mysql: [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 8
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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.

root@(none) 18:47  mysql>

看日志

[root@mysql mysql]# tail slave.err 
2023-07-22T10:41:12.871873Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'screpl@192.168.102.139:3306' - retry-time: 60  retries: 143, Error_code: 2003
2023-07-22T10:42:15.913241Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'screpl@192.168.102.139:3306' - retry-time: 60  retries: 144, Error_code: 2003
2023-07-22T10:43:18.950869Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'screpl@192.168.102.139:3306' - retry-time: 60  retries: 145, Error_code: 2003
2023-07-22T10:44:21.983706Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'screpl@192.168.102.139:3306' - retry-time: 60  retries: 146, Error_code: 2003
2023-07-22T10:45:25.014526Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'screpl@192.168.102.139:3306' - retry-time: 60  retries: 147, Error_code: 2003
2023-07-22T10:46:28.043188Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'screpl@192.168.102.139:3306' - retry-time: 60  retries: 148, Error_code: 2003
2023-07-22T10:47:31.062752Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'screpl@192.168.102.139:3306' - retry-time: 60  retries: 149, Error_code: 2003
2023-07-22T10:47:34.379215Z 7 [Note] Access denied for user 'root'@'localhost' (using password: YES)
2023-07-22T10:48:34.081550Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'screpl@192.168.102.139:3306' - retry-time: 60  retries: 150, Error_code: 2003
2023-07-22T10:49:37.122049Z 1 [ERROR] Slave I/O for channel '': error connecting to master 'screpl@192.168.102.139:3306' - retry-time: 60  retries: 151, Error_code: 2003

看服務(wù)狀態(tài)狀態(tài)

[root@mysql mysql]# systemctl status mysqld
● mysqld.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
   Active: active (running) since 六 2023-07-22 15:22:47 CST; 3h 28min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 6641 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)
    Tasks: 32
   Memory: 272.4M
   CGroup: /system.slice/mysqld.service
           ├─6663 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/slave...
           └─6996 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/...

7月 22 15:22:43 slave systemd[1]: Starting LSB: start and stop MySQL...
7月 22 15:22:47 slave mysqld[6641]: Starting MySQL.... SUCCESS!
7月 22 15:22:47 slave systemd[1]: Started LSB: start and stop MySQL.

云服務(wù)器 --》檢查安全組

mysql連不上,MySQL,mysql,數(shù)據(jù)庫,linux

?文章來源地址http://www.zghlxwxcb.cn/news/detail-778515.html

到了這里,關(guān)于MySQL 連接不上的常見問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • MySQL常見問題處理(三)

    MySQL常見問題處理(三)

    夕陽留戀的不是黃昏,而是朝陽 上一章簡單介紹了MySQL數(shù)據(jù)庫安裝(二), 如果沒有看過, 請觀看上一章 復(fù)制內(nèi)容來源鏈接: https://blog.csdn.net/weixin_48927364/article/details/123556927 以 管理員身份 打開 cmd窗口 ,停止mysq服務(wù),即輸入以下命令,回車 繼續(xù)輸入以下命令,回車 注意不要關(guān)

    2024年02月14日
    瀏覽(17)
  • MySql常見問題(長期更新)

    2023年06月21日
    瀏覽(23)
  • mysql_2.4——安裝常見問題

    mysql_2.4——安裝常見問題

    1. 將MySQL添加到環(huán)境變量 將 mysql 的 bin 目錄地址添加到 系統(tǒng)環(huán)境變量 -- PATH 中 2.?將MySQL添加到服務(wù) 以管理員的方式啟動 cmd (命令提示窗口),使用命令進入到 ` [mysql]bin ` ,執(zhí)行如下命 令。 刪除服務(wù)命令是: 3. mysql端口被占用解決 在 cmd 窗口下執(zhí)行如下命令: 查找正在執(zhí)行的

    2024年02月15日
    瀏覽(46)
  • 「MySQL」MySQL面試題全解析:常見問題與高級技巧詳解

    回答:數(shù)據(jù)庫是一個組織和存儲數(shù)據(jù)的集合,可通過各種方式對數(shù)據(jù)進行訪問、管理和操作。 回答:MySQL是一種開源的關(guān)系型數(shù)據(jù)庫管理系統(tǒng),廣泛用于Web應(yīng)用程序的后端數(shù)據(jù)存儲。 回答:SQL(Structured Query Language)是一種用于管理關(guān)系型數(shù)據(jù)庫的標準語言,用于查詢、插入

    2024年02月10日
    瀏覽(20)
  • 「MySQL運維常見問題及解決方法」

    「MySQL運維常見問題及解決方法」

    ??The Begin??點點關(guān)注,收藏不迷路?? 在某些情況下,我們可能需要查看MySQL數(shù)據(jù)庫的安裝路徑,以便進行一些特定的操作或配置。 步驟1:登錄MySQL數(shù)據(jù)庫 首先,我們需要登錄MySQL數(shù)據(jù)庫??梢允褂妹钚泄ぞ呋蛘邎D形化界面進行登錄。在命令行中,可以使用以下命令登錄:

    2024年02月03日
    瀏覽(24)
  • MySQL 索引常見問題匯總,一次性梳理

    MySQL 索引常見問題匯總,一次性梳理

    hello,大家好,我是張張,「架構(gòu)精進之路」公號作者。 ? 提到MySQL查詢分析,就會涉及到索引相關(guān)知識,要想學(xué)好MySQL,索引是重要且不得不啃下的一環(huán),今天就把MySQL索引常見問題進行匯總,一次性梳理清楚。 文章目錄: 索引 什么是索引? 索引的優(yōu)缺點? 索引的作用?

    2024年02月07日
    瀏覽(88)
  • MYSQL 8.0.32linux 本地安裝步驟及常見問題

    MYSQL 8.0.32linux 本地安裝步驟及常見問題

    1.下載安裝包,根據(jù)各自系統(tǒng)選擇對應(yīng)系統(tǒng)版本及mysql安裝包MySQL :: Download MySQL Community Server, 服務(wù)器可聯(lián)網(wǎng)可用?wget?https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz ?2.上傳安裝包至linux 目錄下,常用/usr/local/mysql ?3. 解壓安裝包:tar -xvf /安裝包目錄/安裝包

    2024年02月09日
    瀏覽(34)
  • linux安裝mysql-8.0.33正確方式及常見問題

    linux安裝mysql-8.0.33正確方式及常見問題

    目錄 獲取mysql下載地址鏈接 ?解壓安裝包 ?復(fù)制文件到安裝目錄 ?添加用戶和用戶屬組修改權(quán)限 ?創(chuàng)建存儲數(shù)據(jù)的文件夾/usr/local/mysql 初始化安裝 修改配置文件 ?創(chuàng)建日志文件并賦予對應(yīng)權(quán)限 ?啟動成功?編輯 創(chuàng)建軟鏈接 之前安裝過mysql,時間比較長忘記安裝步驟了今天就記

    2024年02月12日
    瀏覽(51)
  • QT的mysql(數(shù)據(jù)庫)最佳實踐和常見問題解答

    QT的mysql(數(shù)據(jù)庫)最佳實踐和常見問題解答

    涉及到數(shù)據(jù)庫,首先安利一個軟件Navicat Premium,用來查詢數(shù)據(jù)庫很方便? QMysql驅(qū)動是Qt SQL模塊使用的插件,用于與MySQL數(shù)據(jù)庫進行通信。要編譯QMysql驅(qū)動,您需要滿足以下條件: 您需要安裝MySQL的客戶端庫和開發(fā)頭文件,這些文件通常隨MySQL的安裝程序一起提供,或者可以從

    2024年02月12日
    瀏覽(46)
  • 如何解決MySQL連接不上本地服務(wù)器問題

    MySQL是一個開源的、關(guān)系型數(shù)據(jù)庫管理系統(tǒng),在開發(fā)過程中被廣泛使用。有時候我們可能會遇到MySQL連接不上本地服務(wù)器的問題,這個問題可能由于多種原因引起。本文將從多個方面對此進行詳細闡述,并給出對應(yīng)的代碼示例。 首先,我們需要檢查MySQL是否已經(jīng)啟動。如果My

    2024年02月08日
    瀏覽(19)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包