web-dev-qa-db-ja.com

「MySQLの「root」ユーザーのパスワードをOpenvz VPSで設定できません」

Ubuntu 13.04 64ビットを実行しているOpenvzベースのVPSにmysqlサーバーをインストールしようとしていますが、インストール時にこのエラーが発生し続けます。私は何度も試してみましたが、OSも変更なしで再インストールしました。以下に示すように、エラー2002が表示された後にルートユーザーを設定しようとすると..

問題をグーグルで検索しようとしましたが、このようなものが見つかりませんでした。手伝ってください。

少し早いですがお礼を

root@server1:~# apt-get install mysql-server mysql-common mysql-client          Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libdbd-mysql-Perl libmysqlclient18 mysql-client-5.5 mysql-server-5.5
Suggested packages:
  tinyca mailx
The following NEW packages will be installed:
  libdbd-mysql-Perl libmysqlclient18 mysql-client mysql-client-5.5
  mysql-common mysql-server mysql-server-5.5
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/18.0 MB of archives.
After this operation, 66.9 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Preconfiguring packages ...
 Package configuration
 ──────────────────────────────────────────────────────────────────────────────



┌──────────────────────Configuring mysql-server-5.5─────────────────────────┐
│ While not mandatory, it is highly recommended that you set a password     │
│ for the MySQL administrative "root" user.                                 │
│                                                                           │
│ If this field is left blank, the password will not be changed.            │
│                                                                           │
│ New password for the MySQL "root" user:                                   │
│ ┌───────────────────────────────────────────────────────────────────────┐ │
│ │                                                                       │ │
├─└───────────────────────────────────────────────────────────────────────┘─┤
│                                 <  OK  >                                  │
└───────────────────────────────────────────────────────────────────────────┘







 Package configuration
 ──────────────────────────────────────────────────────────────────────────────





              ┌────────Configuring mysql-server-5.5───────────┐
              │                                               │
              │                                               │
              │ Repeat password for the MySQL "root" user:    │
              │ ┌───────────────────────────────────────────┐ │
              │ │                                           │ │
              ├─└───────────────────────────────────────────┘─┤
              │                   <  OK  >                    │
              └───────────────────────────────────────────────┘







Selecting previously unselected package mysql-common.
(Reading database ... 41054 files and directories currently installed.)
Unpacking mysql-common (from .../mysql-common_5.5.32-0ubuntu0.13.04.1_all.deb) ...
Selecting previously unselected package libmysqlclient18:AMD64.
Unpacking libmysqlclient18:AMD64 (from .../libmysqlclient18_5.5.32-0ubuntu0.13.04.1_AMD64.deb) ...
Selecting previously unselected package libdbd-mysql-Perl.
Unpacking libdbd-mysql-Perl (from .../libdbd-mysql-Perl_4.021-1_AMD64.deb) ...
Selecting previously unselected package mysql-client-5.5.
Unpacking mysql-client-5.5 (from .../mysql-client-5.5_5.5.32-0ubuntu0.13.04.1_AMD64.deb) ...
Processing triggers for man-db ...
Setting up mysql-common (5.5.32-0ubuntu0.13.04.1) ...
Selecting previously unselected package mysql-server-5.5.
(Reading database ... 41140 files and directories currently installed.)
Unpacking mysql-server-5.5 (from .../mysql-server-5.5_5.5.32-0ubuntu0.13.04.1_AMD64.deb) ...
Selecting previously unselected package mysql-client.
Unpacking mysql-client (from .../mysql-client_5.5.32-0ubuntu0.13.04.1_all.deb) ...
Selecting previously unselected package mysql-server.
Unpacking mysql-server (from .../mysql-server_5.5.32-0ubuntu0.13.04.1_all.deb) ...
Processing triggers for man-db ...
Setting up libmysqlclient18:AMD64 (5.5.32-0ubuntu0.13.04.1) ...
Setting up libdbd-mysql-Perl (4.021-1) ...
Setting up mysql-client-5.5 (5.5.32-0ubuntu0.13.04.1) ...
Setting up mysql-server-5.5 (5.5.32-0ubuntu0.13.04.1) ...
invoke-rc.d: policy-rc.d denied execution of stop.
 Package configuration
 ──────────────────────────────────────────────────────────────────────────────

┌───────────────────────Configuring mysql-server-5.5─────────────────────────┐
│ Unable to set password for the MySQL "root" user                           │
│                                                                            │
│ An error occurred while setting the password for the MySQL                 │
│ administrative user. This may have happened because the account already    │
│ has a password, or because of a communication problem with the MySQL       │
│ server.                                                                    │
│                                                                            │
│ You should check the account's password after the package installation.    │
│                                                                            │
│ Please read the /usr/share/doc/mysql-server-5.5/README.Debian file for     │
│ more information.                                                          │
│                                                                            │
│                                                                            │
├────────────────────────────────────────────────────────────────────────────┤
│                                 <  OK  >                                   │
└────────────────────────────────────────────────────────────────────────────┘



invoke-rc.d: policy-rc.d denied execution of start.
Setting up mysql-client (5.5.32-0ubuntu0.13.04.1) ...
Setting up mysql-server (5.5.32-0ubuntu0.13.04.1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
root@server1:~# Sudo mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Enter current password for root (enter for none):
5
David

私はまったく同じ問題を抱えていたが、それはメモリ不足の問題であることが判明した。ホストでこのスクリプトを実行すると、修正されました。

#!/bin/bash    
cid=104
vzctl set ${cid} --vmguarpages 1024M --save
vzctl set ${cid} --oomguarpages 1024M --save
vzctl set ${cid} --privvmpages 1024M:1024M --save

1024をコンテナに必要なメモリ量に自由に変更してください。 104をコンテナのIDに変更する必要もあります。

1
Programster

以下のコマンドを使用して、mysqlサーバーのルートパスワードを変更します。

Sudo dpkg-reconfigure mysql-server-5.5

1
PKumar

なぜこれが起こっているのかを説明することはできませんが、Sudo mysql_secure_installationを実行するために失敗した試行の後にMySQLのルートパスワードを設定する回避策は、このコマンドを実行することです。

mysqladmin -u root -p '' password '<new_password>'

* <new_password> =新しいパスワード

0
kos

まず、mysqlサーバーが実際にローリングしているかどうかを確認します。ルート実行として:

service mysql restart

エラーが発生しない場合は読み取りを続けます。そうでない場合は、apt-get install --reinstall mysql-serverを使用してmysqlサーバーを再インストールします。

次に、mysql構成ファイル/etc/mysql/my.cnfを確認し、次のパラメーターを探します。

user = mysql
...
bind-address = 127.0.0.1

必要に応じて変更してサーバーを再起動し、次のいずれかで接続を試みます。

mysql -u root
mysql -u root -p
mysql -u root -p -h localhost
mysql -u root -p -h 127.0.0.1

それでもログインできない場合は、/etc/apparmor.d/usr.sbin.mysqldを次のように変更してください。

検索する

/var/run/mysqld/mysqld.pid w,
/var/run/mysqld/mysqld.sock w,

と置換する

/{,var/}run/mysqld/mysqld.pid w,
/{,var/}run/mysqld/mysqld.sock w,

service apparmor restartを使用してapparmorサービスを再起動し、mysqlへの接続を再試行します。それでもうまくいかない場合は、mysqlサーバーを停止し、許可テーブルなしで再実行します。

Sudo service mysql stop
Sudo mysqld --skip-grant-tables &

これで、パスワード(mysql -u root)なしでmysqlにログインできるはずです。ユーザーテーブルで何が起こっているかを見てください。

select Host, User, Password from mysql.user;

4人のrootユーザーが必要です。ホスト名が正しいことと、すべてにパスワードがあることを確認してください。新しいパスワードでパスワードをリセットしてみてください。

update mysql.user set Password=PASSWORD('YOUR-PASSWORD');
flush privileges;
exit;

ここでSudo killall mysqldSudo service mysql restartを選択し、新しい資格情報で接続を再試行します。

0
Cubiq