0

I wanted to install and run MySQL with the command line, I'm on Ubuntu 16.04 Desktop. So I installed it I think, then I got this:

$ mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.socket' (2)

I tried:

$ sudo service mysql stop
$ sudo /usr/bin/mysqld_safe --skip-grant-tables &
[2] 28542
$ 2017-01-10T21:31:15.452971Z mysqld_safe Logging to syslog.
2017-01-10T21:31:15.457460Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-01-10T21:31:15.489409Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2017-01-10T21:32:56.365323Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
^C
[2]+  Fini                    sudo /usr/bin/mysqld_safe --skip-grant-tables

$ mysql -h localhost
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

$ /etc/init.d/mysql.server start
[....] Starting mysql.server (via systemctl): mysql.server.serviceJob for mysql.server.service failed because the control process exited with error code. See "systemctl status mysql.server.service" and "journalctl -xe" for details.
failed!

$ systemctl status mysql.server.service
● mysql.server.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/init.d/mysql.server; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since mar. 2017-01-10 22:56:04 CET; 5min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 30182 ExecStart=/etc/init.d/mysql.server start (code=exited, status=1/FAI

janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Aborting
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Binlog end
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Shutting down plugin 'CSV'
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Shutting down plugin 'MyISAM'
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: /usr/sbin/mysqld: Shutdown co
janv. 10 22:56:04 lauricot-Aspire-7739G mysql.server[30182]: .......................
janv. 10 22:56:04 lauricot-Aspire-7739G systemd[1]: mysql.server.service: Control pr
janv. 10 22:56:04 lauricot-Aspire-7739G systemd[1]: Failed to start LSB: start and s
janv. 10 22:56:04 lauricot-Aspire-7739G systemd[1]: mysql.server.service: Unit enter
janv. 10 22:56:04 lauricot-Aspire-7739G systemd[1]: mysql.server.service: Failed wit

$ journalctl -xe
janv. 10 22:55:53 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:55:54 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to lock ./ibda
janv. 10 22:55:54 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:55:55 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to lock ./ibda
janv. 10 22:55:55 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:55:56 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to lock ./ibda
janv. 10 22:55:56 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:55:57 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to lock ./ibda
janv. 10 22:55:57 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:55:58 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to lock ./ibda
janv. 10 22:55:58 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:55:59 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to lock ./ibda
janv. 10 22:55:59 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:56:00 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to lock ./ibda
janv. 10 22:56:00 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:56:01 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to lock ./ibda
janv. 10 22:56:01 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:56:02 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to lock ./ibda
janv. 10 22:56:02 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:56:03 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to lock ./ibda
janv. 10 22:56:03 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Check that you do not
janv. 10 22:56:03 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Unable to open the fi
janv. 10 22:56:03 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Operating system erro
janv. 10 22:56:03 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Error number 11 means
janv. 10 22:56:03 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Some operating system
janv. 10 22:56:03 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Cannot open datafile 
janv. 10 22:56:03 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Could not open or cre
janv. 10 22:56:03 lauricot-Aspire-7739G mysqld[30749]: InnoDB: Plugin initialization
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Plugin 'InnoDB' init function
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Plugin 'InnoDB' registration 
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Failed to initialize plugins.
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Aborting
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Binlog end
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Shutting down plugin 'CSV'
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: Shutting down plugin 'MyISAM'
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld[30749]: /usr/sbin/mysqld: Shutdown co
janv. 10 22:56:04 lauricot-Aspire-7739G mysqld_safe[31007]: mysqld from pid file /va
janv. 10 22:56:04 lauricot-Aspire-7739G mysql.server[30182]: .......................
janv. 10 22:56:04 lauricot-Aspire-7739G systemd[1]: mysql.server.service: Control pr
janv. 10 22:56:04 lauricot-Aspire-7739G systemd[1]: Failed to start LSB: start and s
-- Subject: L'unité (unit) mysql.server.service a échoué
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- L'unité (unit) mysql.server.service a échoué, avec le résultat failed.
janv. 10 22:56:04 lauricot-Aspire-7739G systemd[1]: mysql.server.service: Unit enter
janv. 10 22:56:04 lauricot-Aspire-7739G systemd[1]: mysql.server.service: Failed wit
janv. 10 22:56:04 lauricot-Aspire-7739G polkitd(authority=local)[867]: Unregistered 
lines 1280-1327/1327 (END)

Sorry, there's some french words in the code. I don't really understand as I'm a noob in programming. I want to know what's going wrong here and how to fix it.

EDIT

Finally, everything works fine. I chose a solution (if we can call it a solution) very radical: I simply remade the installation of my operating system. A complete rebootstrapping of the PC, then a reinstalment of mysql-server. I know that it does not help me to know from where the problem came but at least I can continue to learn how to code, and who knows, perhaps, one day I could understand what happened to me, ahah. Thank you, to all those answered me =) Peace

lauricot
  • 1
  • 2
  • Did you Google that error? (And by the way, your English really isn't that bad). – Carcigenicate Jan 10 '17 at 22:34
  • Maybe check this out http://stackoverflow.com/questions/15450091/for-a-newbie-error-2002-hy000-cant-connect-to-local-mysql-server-through-so i.e. mysql server might not be running – aggaton Jan 10 '17 at 22:37
  • Possible duplicate of [For a newbie: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'](http://stackoverflow.com/questions/15450091/for-a-newbie-error-2002-hy000-cant-connect-to-local-mysql-server-through-so) – Joe C Jan 10 '17 at 22:49
  • @Carcigenicate : yeah, I google it, many times, and tried almost all I found. No results. (Thank you !) – lauricot Jan 14 '17 at 11:49
  • @aggaton: I'll see if I can fix it with what you gave me. Even if I'm not running on Mac.. I hope it will work anyway. Thank you. – lauricot Jan 14 '17 at 11:57
  • @JoeC : It's the same link. I'll try and keep you up to date. Thank you. – lauricot Jan 14 '17 at 11:57
  • Try this: `mysql -u root -p -h127.0.0.1` or `mysql -u root -p -hlocalhost`. Keep in mind that there should be no spacing between _-h_ and _localhost_ – mondieki Mar 27 '17 at 10:25

1 Answers1

0

Did you create a user/pass during install? If yes, it's easier to connect to MySQL using root credentials and then create a regular user for you.

Take a look on MySQL install guide - Adding User Accounts.

BTW, to know if MySQL is running (despite the service) you can try to telnet 1433 port.

jfneis
  • 2,139
  • 18
  • 31
  • When I hit this : `$ mysql --user=root mysql` I've this : `ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)` and when I try with password : `$ mysql --user=root mysql -p` I've got this : `Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)` Thank you. – lauricot Jan 14 '17 at 12:01
  • @lauricot did you started mysql? Try typing "service mysql start" in the command line. – jfneis Jan 17 '17 at 14:32