5

I'm trying to install mysql server on my Openvz based VPS running Ubuntu 13.04 64bit and i keep getting this error at the install. I tried multiple times and i also re installed the os with no change at all. If i try to set the root user after i get error 2002 as you can see below..

I tried to google the problem but i didn't find anything like this, could you please help me?

Thank in advance

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):
7
  • please post result of: cat /etc/mysql/my.cnf |grep bind-address and ps aux |grep mysql
    – Cubiq
    Aug 27, 2013 at 15:46
  • Here you are @Cubiq: root@server1:~# cat /etc/mysql/my.cnf |grep bind-address bind-address = 127.0.0.1 root@server1:~# ps aux |grep mysql root 3971 0.0 0.0 6508 796 pts/1 S+ 13:54 0:00 grep --color=auto mysql
    – David
    Aug 27, 2013 at 17:55
  • you don't seem to have the mysql service running. can you try service mysql start ?
    – Cubiq
    Aug 27, 2013 at 19:03
  • It says it's already running...root@server1:~# service mysql status mysql start/post-start, process 21830 post-start process 21831
    – David
    Aug 27, 2013 at 19:16
  • can you log in with mysql -uroot without password? and with mysql -uroot -p
    – Cubiq
    Aug 27, 2013 at 22:17

4 Answers 4

1

I had the exact same issue and it turned out to be a lack of memory issue. Running this script on the host fixed it for me:

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

Feel free to change 1024 to whatever amount of memory you want your container to have. You will also need to change 104 to the ID of your container.

1

Use the command below to change the root password for mysql server

sudo dpkg-reconfigure mysql-server-5.5

2
  • 1
    worked for me: the normal setup somehow did not accept my password (maybe to exotic special chars..). with this command i used a different password and it worked!
    – Benjamin
    Mar 22, 2016 at 17:23
  • Didn't work for me: same error as before.
    – Shautieh
    Oct 28, 2016 at 12:13
0

First of all check if you the mysql server is actually rolling. As root run:

service mysql restart

If no errors occur continue reading otherwise reinstall the mysql server with apt-get install --reinstall mysql-server.

Next check the mysql configuration file /etc/mysql/my.cnf and look for the following parameters:

user = mysql
...
bind-address = 127.0.0.1

Change them if needed are reboot the server, then try to connect with one of the following:

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

If you can't still login try to alter the /etc/apparmor.d/usr.sbin.mysqld like so:

Search for

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

Replace with

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

Restart the apparmor service with service apparmor restart and retry to connect to mysql. If still no luck, stop the mysql server and rerun it without grant tables:

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

Now you should be able to login to mysql without password (mysql -u root). Have a look what is going on your user table:

select Host, User, Password from mysql.user;

You should have 4 root users, check that the hostname is correct and that all have a password. Try to reset the password with a new one:

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

Now sudo killall mysqld and sudo service mysql restart and retry to connect with the new credentials.

9
  • Restarted mysql service, my.cnf was ok, mysql -u root and similar always gave me ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2), apparmor was previously uninstalled, i reinstalled it and edited the file, restarted apparmor, stopped and started mysql service with sudo mysqld --skip-grant-tables & and i got alway the same error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) :(
    – David
    Aug 28, 2013 at 9:25
  • ls -la /var/run/mysqld
    – Cubiq
    Aug 28, 2013 at 9:27
  • root@server1:~# ls -la /var/run/mysqld total 0 drwxr-xr-x 2 mysql root 40 Aug 28 05:09 . drwxr-xr-x 18 root root 720 Aug 28 05:09 ..
    – David
    Aug 28, 2013 at 9:28
  • the server doesn't seem to be running
    – Cubiq
    Aug 28, 2013 at 9:33
  • It always hangs when trying to start but if i press Ctrl+C and try again it says start: Job is already running: mysql
    – David
    Aug 28, 2013 at 9:41
0

I can't explain why this is happening, but a workaround to set MySQL's root password after the failed attempt in order to possibly make sudo mysql_secure_installation run is to run this command:

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

*<new_password> = new password

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .