最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

mysql使用報(bào)錯(cuò)1142(42000)的問(wèn)題及解決

 更新時(shí)間:2023年08月30日 09:14:12   作者:Ahri-情書  
這篇文章主要介紹了mysql使用報(bào)錯(cuò)1142(42000)的問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

mysql使用報(bào)錯(cuò)1142(42000)

在學(xué)習(xí)mysql的時(shí)候,一頓蜜汁操作,再次使用mysql的時(shí)候發(fā)現(xiàn),不管用啥子命令,都出現(xiàn)了一個(gè)報(bào)錯(cuò)

mysql> select user,password from mysql.user;
ERROR 1142 (42000): SELECT command denied to user ‘root’@‘localhost’ for table ‘user’

看了一下報(bào)錯(cuò)信息,權(quán)限不夠。。。

那就是沒有權(quán)限了,so,給他權(quán)限就好了

step01

退出數(shù)據(jù)庫(kù)并且關(guān)閉mysql服務(wù)

 mysql> quit
 Bye
 [root@jinch ~]# /etc/init.d/mysqld stop
 Shutting down MySQL.. SUCCESS! 

step02

安全模式啟動(dòng)mysql,root用戶登錄

 [root@jinch ~]# mysqld_safe --skip-grant-tables &
 [root@jinch ~]# mysql -uroot -p123 mysql

step03

切換數(shù)據(jù)庫(kù)&查看表信息中的root用戶的localhost權(quán)限

 mysql> use mysql;
 Database changed
 mysql> show tables;
 +---------------------------+
 | Tables_in_mysql           |
 +---------------------------+
 | columns_priv              |
 | db                        |
 | event                     |
 | func                      |
 | general_log               |
 | help_category             |
 | help_keyword              |
 | help_relation             |
 | help_topic                |
 | innodb_index_stats        |
 | innodb_table_stats        |
 | ndb_binlog_index          |
 | plugin                    |
 | proc                      |
 | procs_priv                |
 | proxies_priv              |
 | servers                   |
 | slave_master_info         |
 | slave_relay_log_info      |
 | slave_worker_info         |
 | slow_log                  |
 | tables_priv               |
 | time_zone                 |
 | time_zone_leap_second     |
 | time_zone_name            |
 | time_zone_transition      |
 | time_zone_transition_type |
 | user                      |
 +---------------------------+
 28 rows in set (0.00 sec)
 mysql> select * from user where user='root' and host='localhost'\G;
 *************************** 1. row ***************************
                   Host: localhost
                   User: root
               Password: *23AE809DDACAF96AF0FD78ED04B6A265E05AA257
            Select_priv: N
            Insert_priv: N
            Update_priv: N
            Delete_priv: N
            Create_priv: N
              Drop_priv: N
            Reload_priv: N
          Shutdown_priv: N
           Process_priv: N
              File_priv: N
             Grant_priv: N
        References_priv: N
             Index_priv: N
             Alter_priv: N
           Show_db_priv: N
             Super_priv: N
  Create_tmp_table_priv: N
       Lock_tables_priv: N
           Execute_priv: N
        Repl_slave_priv: N
       Repl_client_priv: N
       Create_view_priv: N
         Show_view_priv: N
    Create_routine_priv: N
     Alter_routine_priv: N
       Create_user_priv: N
             Event_priv: N
           Trigger_priv: N
 Create_tablespace_priv: N
               ssl_type: 
             ssl_cipher: 
            x509_issuer: 
           x509_subject: 
          max_questions: 0
            max_updates: 0
        max_connections: 0
   max_user_connections: 0
                 plugin: mysql_native_password
  authentication_string: NULL
       password_expired: N
 1 row in set (0.00 sec)
 ERROR: 
 No query specified

這里發(fā)現(xiàn)全部都是N ,表示root用戶本地登陸沒有權(quán)限

step04

修改root用戶的localhost權(quán)限(兩種寫法)

寫法1:

mysql> update mysql.user set Grant_priv='Y',Super_priv='Y' where user='root';
mysql> flush privileges;
mysql>grant all on *.* to 'root'@'localhost';

寫法2:

 mysql> update user set `Insert_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Update_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Delete_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Create_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Drop_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Reload_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Shutdown_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Process_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `File_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Grant_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `References_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Index_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Alter_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Show_db_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Super_priv` ='Y',`Create_tmp_table_priv` = 'Y' where user='root'' and host='localhost';
 mysql> update user set `Lock_tables_priv` ='Y' where user='root' and host='localhost';  
 mysql> update user set `Execute_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Repl_slave_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Repl_client_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Create_view_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Show_view_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Create_routine_priv` ='Y' where user='root' and host='localhost'';
 mysql> update user set `Alter_routine_priv` ='Y' where user='root' and host='localhost';;
 mysql> update user set `Create_user_priv` ='Y' where user='root' and host='localhost'; 
 mysql> update user set `Event_priv` ='Y' where user='root' and host='localhost';
 mysql> update user set `Trigger_priv` ='Y' where user='root' and host='localhost';
 mysql> flush privileges;
 Query OK, 0 rows affected (0.00 sec)

我這里有點(diǎn)傻。。。自己一個(gè)一個(gè)敲了一遍,可以直接用‘,’ 分割一次寫完的,,,

step05

退出&重啟&登陸

 mysql> quit
 Bye
 [root@jinch ~]# /etc/init.d/mysqld restart
 Shutting down MySQL.. SUCCESS! 
 Starting MySQL.. SUCCESS! 
 [root@jinch ~]# mysql -uroot -p123

step06

切換庫(kù)

 mysql> use mysql;
 Reading table information for completion of table and column names
 You can turn off this feature to get a quicker startup with -A
 Database changed

step07

查看表信息

 mysql> select * from user\G;
 *************************** 1. row ***************************
                   Host: localhost
                   User: root
               Password: *23AE809DDACAF96AF0FD78ED04B6A265E05AA257
            Select_priv: Y
            Insert_priv: Y
            Update_priv: Y
            Delete_priv: Y
            Create_priv: Y
              Drop_priv: Y
            Reload_priv: Y
          Shutdown_priv: Y
           Process_priv: Y
              File_priv: Y
             Grant_priv: Y
        References_priv: Y
             Index_priv: Y
             Alter_priv: Y
           Show_db_priv: Y
             Super_priv: Y
  Create_tmp_table_priv: Y
       Lock_tables_priv: Y
           Execute_priv: Y
        Repl_slave_priv: Y
       Repl_client_priv: Y
       Create_view_priv: Y
         Show_view_priv: Y
    Create_routine_priv: Y
     Alter_routine_priv: Y
       Create_user_priv: Y
             Event_priv: Y
           Trigger_priv: Y
 Create_tablespace_priv: N
               ssl_type: 
             ssl_cipher: 
            x509_issuer: 
           x509_subject: 
          max_questions: 0
            max_updates: 0
        max_connections: 0
   max_user_connections: 0
                 plugin: mysql_native_password
  authentication_string: NULL
       password_expired: N
 1 row in set (0.01 sec)
 ERROR: 
 No query specified
 權(quán)限已經(jīng)基本都有了

測(cè)試一下

 mysql> create database jinc;
 Query OK, 1 row affected (0.00 sec)
 mysql> select user,host from mysql.user;
 +------+-----------+
 | user | host      |
 +------+-----------+
 | root | localhost |
 +------+-----------+
 1 row in set (0.00 sec)
 mysql> drop database jinc;
 Query OK, 0 rows affected (0.00 sec)

好了,基本的權(quán)限又回來(lái)了

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Django+mysql配置與簡(jiǎn)單操作數(shù)據(jù)庫(kù)實(shí)例代碼

    Django+mysql配置與簡(jiǎn)單操作數(shù)據(jù)庫(kù)實(shí)例代碼

    這篇文章主要介紹了Django+mysql配置與簡(jiǎn)單操作數(shù)據(jù)庫(kù)實(shí)例,需要的朋友可以參考下
    2017-07-07
  • 關(guān)于MySQL 大批量插入時(shí)如何過(guò)濾掉重復(fù)數(shù)據(jù)

    關(guān)于MySQL 大批量插入時(shí)如何過(guò)濾掉重復(fù)數(shù)據(jù)

    這篇文章主要介紹關(guān)于MySQL 大批量插入時(shí)如何過(guò)濾重復(fù)數(shù)據(jù),比如線上庫(kù)有6個(gè)表存在重復(fù)數(shù)據(jù),其中2個(gè)表比較大,96萬(wàn)+和30萬(wàn)+,因?yàn)橹疤幚磉^(guò)相同的問(wèn)題,就直接拿來(lái)了上次的Python去重腳本,腳本很簡(jiǎn)單,就是連接數(shù)據(jù)庫(kù),查出來(lái)重復(fù)數(shù)據(jù),循環(huán)刪除,需要的朋友可以參考下
    2021-09-09
  • MySQL啟動(dòng)報(bào)錯(cuò):InnoDB表空間丟失的問(wèn)題排查與解決方案

    MySQL啟動(dòng)報(bào)錯(cuò):InnoDB表空間丟失的問(wèn)題排查與解決方案

    在MySQL數(shù)據(jù)庫(kù)的日常運(yùn)維中,InnoDB表空間丟失是一個(gè)較為常見的問(wèn)題,本文將深入分析該問(wèn)題的原因,并提供詳細(xì)的解決方法和預(yù)防措施,希望對(duì)大家有所幫助
    2025-07-07
  • mysql 8.0.15 安裝圖文教程及數(shù)據(jù)庫(kù)基礎(chǔ)

    mysql 8.0.15 安裝圖文教程及數(shù)據(jù)庫(kù)基礎(chǔ)

    這篇文章主要為大家詳細(xì)介紹了mysql 8.0.15 安裝方法圖文教程,及數(shù)據(jù)庫(kù)基礎(chǔ)知識(shí),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-03-03
  • Mysql字符串截取及獲取指定字符串中的數(shù)據(jù)

    Mysql字符串截取及獲取指定字符串中的數(shù)據(jù)

    小編童鞋最近接了一個(gè)新需求,需要在MySql的字段中截取一段字符串中的特定字符,下面小編把我的核心代碼分享給大家,對(duì)mysql 字符串截取相關(guān)知識(shí)感興趣的朋友一起看看吧
    2019-11-11
  • MySql超詳細(xì)講解表的用法

    MySql超詳細(xì)講解表的用法

    這篇文章主要為大家詳細(xì)介紹了MySQL數(shù)據(jù)庫(kù)中表常用的一些操作方法,文中的示例代碼講解詳細(xì), 對(duì)我們學(xué)習(xí)MySQL有一定幫助,需要的可以參考一下
    2022-09-09
  • Linux服務(wù)上MySQL啟動(dòng)、重啟和關(guān)閉的操作方法

    Linux服務(wù)上MySQL啟動(dòng)、重啟和關(guān)閉的操作方法

    MySQL是一種廣泛使用的開源關(guān)系型數(shù)據(jù)庫(kù)管理系統(tǒng),常用于各種規(guī)模的應(yīng)用程序中,在Linux服務(wù)器上管理MySQL服務(wù)是一個(gè)基本的運(yùn)維任務(wù),本文將詳細(xì)介紹如何在Linux系統(tǒng)上啟動(dòng)、重啟和關(guān)閉MySQL服務(wù),涵蓋不同Linux發(fā)行版(如Ubuntu和CentOS)的操作方法
    2024-11-11
  • MySQL學(xué)習(xí)第二天 安裝和配置mysql winx64

    MySQL學(xué)習(xí)第二天 安裝和配置mysql winx64

    MySQL學(xué)習(xí)第二天,主要為大家詳細(xì)介紹了在Windows 64位操作系統(tǒng)下安裝和配置MySQL的具體步驟,整理一份mysql winx64安裝配置方法教程,感興趣的小伙伴們可以參考一下
    2016-05-05
  • MySQL開啟遠(yuǎn)程訪問(wèn)權(quán)限的完整步驟記錄

    MySQL開啟遠(yuǎn)程訪問(wèn)權(quán)限的完整步驟記錄

    MySQL是常用的關(guān)系型數(shù)據(jù)庫(kù),默認(rèn)僅支持本地訪問(wèn),若需更靈活管理,可通過(guò)遠(yuǎn)程連接突破限制,實(shí)現(xiàn)跨主機(jī)操作,這篇文章主要介紹了MySQL開啟遠(yuǎn)程訪問(wèn)權(quán)限的完整步驟,需要的朋友可以參考下
    2025-06-06
  • mysql?中的備份恢復(fù),分區(qū)分表,主從復(fù)制,讀寫分離

    mysql?中的備份恢復(fù),分區(qū)分表,主從復(fù)制,讀寫分離

    這篇文章主要介紹了mysql?中的備份恢復(fù),分區(qū)分表,主從復(fù)制,讀寫分離,文章圍繞主題展開詳細(xì)的內(nèi)容戒殺,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-09-09

最新評(píng)論

怀来县| 台山市| 阿拉善右旗| 广汉市| 哈密市| 通江县| 城市| 新余市| 古蔺县| 开原市| 马边| 微博| 汕尾市| 西乌珠穆沁旗| 扎赉特旗| 琼结县| 繁昌县| 长子县| 巫山县| 专栏| 登封市| 萨迦县| 泰宁县| 久治县| 陆丰市| 金川县| 阿合奇县| 成武县| 清河县| 阿拉善盟| 泾阳县| 陕西省| 通许县| 衡阳县| 新化县| 桐梓县| 蓬溪县| 咸宁市| 仁布县| 邵阳市| 全椒县|