1

これは何度も聞かれる質問であることは知っていますが、他のトピックから解決策を見つけることができないようです.

私が試したこと:

  • mysql-serverの再インストール(クライアントではない)
  • chown mysql:mysql /var/lib/mysql
  • すべてが正しいと思われる my.cnf をチェックアウトしました
  • bind-address を localhost に変更しました
  • ある時点で、ソケットファイルがないように見え、

    sudo find / -type s | grep mysqld.sock結果は出ません。


編集

入力mysql_config --socketしたところ、現在ソケットファイルが配置されているようです/var/run/mysqld/mysqld.sock

apparmor_statusまた、次の結果が得られたことを確認しました。

apparmor module is loaded.
14 profiles are loaded.
14 profiles are in enforce mode.
   /sbin/dhclient
   /usr/bin/evince
   /usr/bin/evince-previewer
   /usr/bin/evince-previewer//sanitized_helper
   /usr/bin/evince-thumbnailer
   /usr/bin/evince-thumbnailer//sanitized_helper
   /usr/bin/evince//sanitized_helper
   /usr/lib/NetworkManager/nm-dhcp-client.action
   /usr/lib/connman/scripts/dhclient-script
   /usr/lib/cups/backend/cups-pdf
   /usr/sbin/cups-browsed
   /usr/sbin/cupsd
   /usr/sbin/mysqld
   /usr/sbin/tcpdump
0 profiles are in complain mode.
3 processes have profiles defined.
0 processes are in enforce mode.
0 processes are in complain mode.
3 processes are unconfined but have a profile defined.
   /sbin/dhclient (1089) 
   /usr/sbin/cups-browsed (1415) 
   /usr/sbin/cupsd (16608) 

結局、これ/etc/init.d/mysql startはまだ失敗します

my.cnf の設定

[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqld]
#
# * Basic Settings
#
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

チェックアウトして、次のレポート/var/log/error.logを試してみると# /etc/init.d/mysql start、ログから次のレポートが表示されます。

150528 22:58:19 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
150528 22:58:19 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
150528 22:58:19 [Note] /usr/sbin/mysqld (mysqld 5.5.43-0ubuntu0.14.04.1) starting as process 14608 ...
150528 22:58:19 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
150528 22:58:19 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
150528 22:58:19 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
150528 22:58:19 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
150528 22:58:19 InnoDB: The InnoDB memory heap is disabled
150528 22:58:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150528 22:58:19 InnoDB: Compressed tables use zlib 1.2.8
150528 22:58:19 InnoDB: Using Linux native AIO
150528 22:58:19 InnoDB: Initializing buffer pool, size = 128.0M
150528 22:58:19 InnoDB: Completed initialization of buffer pool
150528 22:58:19 InnoDB: highest supported file format is Barracuda.
150528 22:58:19  InnoDB: Waiting for the background threads to start
150528 22:58:20 InnoDB: 5.5.43 started; log sequence number 140421610
150528 22:58:20 [Note] Server hostname (bind-address): 'localhost'; port: 3306
150528 22:58:20 [Note]   - 'localhost' resolves to '127.0.0.1';
150528 22:58:20 [Note] Server socket created on IP: '127.0.0.1'.
150528 22:58:20 [ERROR] /usr/sbin/mysqld: Can't find file: './mysql/host.frm' (errno: 13)
150528 22:58:20 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find file: './mysql/host.frm' (errno: 13)
150528 22:58:20 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

誰かが私のデータベースを失うことなくそれを修正する方法を教えてくれますか

4

3 に答える 3

0

データ ディレクトリを初期化していない場合は、開始する前に初期化しますmysqld

mysql が提供するこれら 2 つのスクリプトのいずれかを実行できます。シェル プロンプトから次のように実行します。

# mysql_secure_installation

また

# mysql_install_db --user=mysql \
         --basedir=<path to mysql install dir> \
         --datadir=/var/lib/mysql/data

mysql_install_dbオプションで呼び出さmysqldれます。--bootstrap--skip-grant-tables

于 2015-05-29T07:36:49.220 に答える
0

あなたのmysqlのインストールはホースされています:

150528 22:58:20 [ERROR] /usr/sbin/mysqld: Can't find file: './mysql/host.frm' (errno: 13)

そもそも起動していないため、ソケットファイルがありません。内部/コア データベースからデータが失われていmysqlます。これは非常に悪い兆候です。

于 2015-05-28T22:05:42.970 に答える