deepin系統安裝mysql

deepin系統安裝mysql

系統信息

deepin 15.11 桌面版

64位

apt-get 源 爲 阿里雲

安裝mysql

最好在deepin不安裝其他軟件的時候安裝mysql,防止依賴衝突!

  1. 使用apt方式直接安裝

    sudo apt-get install -y mysql-server mysql-client

  2. 設置密碼

    sudo mysql -uroot -p

  3. 分別執行以下命令,注意將密碼修改

    grant all on . to root@“localhost”;

    update mysql.user set authentication_string=password(‘這裏是你的密碼’) where user='root’and Host = ‘localhost’;

    flush privileges;

  4. 登錄測試

    mysql -uroot -p

無法登錄

如果已經完成了上述操作,但是無法登錄mysql,你需要執行以下命令:

  1. mysql身份驗證過程已調用“ unix_socket”(可能與數據庫到mariadb的部分遷移有關,現已刪除)。要使所有內容恢復正常工作,請執行su:

    sudo su

  2. 執行以下

    /etc/init.d/mysql stop
    mysqld_safe --skip-grant-tables &
    mysql -uroot

    這將完全停止mysql,繞過用戶身份驗證(無需密碼)並使用用戶“ root”連接到mysql。

  3. 在mysql控制檯中,使用mysql管理數據庫:

    use mysql;

  4. 要將根密碼重設爲mynewpassword(根據需要更改)

    update user set password=PASSWORD(“這裏是你的密碼”) where User=‘root’;

  5. 覆蓋身份驗證方法,刪除unix_socket請求(以及所有其他內容),恢復正常且有效的密碼

    update user set plugin=“mysql_native_password”;

  6. 退出mysql控制檯

    quit;

  7. 停止並啓動與mysql有關的所有內容:

    /etc/init.d/mysql stop
    kill -9 $(pgrep mysql)
    /etc/init.d/mysql start

  8. exit su 模式

  9. 使用root登錄

    mysql -u root -p

大小寫敏感

  1. cd /etc/mysql/ 目錄發現以下文件

    conf.d      debian-start  mariadb.conf.d  my.cnf.fallback
    debian.cnf  mariadb.cnf   my.cnf
    
  2. 需要修改 my.cnf

    sudo vi my.cnf

  3. 你可以看到以下內容

    # The MariaDB configuration file
    #
    # The MariaDB/MySQL tools read configuration files in the following order:
    # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
    # 2. "/etc/mysql/conf.d/*.cnf" to set global options.
    # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
    # 4. "~/.my.cnf" to set user-specific options.
    #
    # If the same option is defined multiple times, the last one will apply.
    #
    # One can use all long options that the program supports.
    # Run program with --help to get a list of available options and with
    # --print-defaults to see which it would actually understand and use.
    
    #
    # This group is read both both by the client and the server
    # use it for options that affect everything
    #
    [client-server]
    
    # Import all .cnf files from configuration directory
    !includedir /etc/mysql/conf.d/
    !includedir /etc/mysql/mariadb.conf.d/
    

    ​ 可以詳細看看以上註釋內容,/etc/mysql/my.cnf 是默認的總體設置,百度一大堆修改mysql大小寫敏感之後,都說修改 my.cnf[mysqld]下添加啊lower_case_table_names=1.但是這個文件中並沒有這個[mysqld],這很令人蛋疼…我嘗試過直接添加lower_case_table_names,但是很遺憾,並沒有啥用.這裏就不解釋我經歷的過程,直接陳述解決方式.

    1. 修改my.cnf,在下面直接添加
    [mysqld]
    lower_case_table_names=1
    
    1. 然後重啓mysql服務

    service mysqld start

    1. 這時候你可以登錄mysql,嘗試直接使用大寫來查詢表,如下

      mysql -uroot -p
      use demo;
      select * from DEMO_TABLE;
      select * from demo_table;
      

      如果大寫報錯的話,你可能需要執行

      set @lower_case_table_names=1;

      然後重試以上操作.

發佈了26 篇原創文章 · 獲贊 3 · 訪問量 4558
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章