2

I'm new in Linux, freshly installed a Debian Jessie (8) OS and need to work with MySQL. The hostname is,

hostname -f

It prints, debian8

When I type in the terminal,

sudo dpkg --get-selections | grep mysql

I get the output back,

libdbd-mysql-perl               install
libmysqlclient18:amd64              install
mysql-client-5.5                install
mysql-common                    install
mysql-server                    install
mysql-server-5.5                install
mysql-server-core-5.5               install
php5-mysql                  install

When I type in the terminal,

sudo apt-cache show mysql

The output is,

N: Unable to locate package mysql
E: No packages found
chaklader@debian8:/home/cx-components$ 

When I type in the terminal,

locate mysql

The output is,

/usr/lib/libreoffice/program/libmysqllo.so
/usr/share/bash-completion/completions/mysql
/usr/share/bash-completion/completions/mysqladmin
/usr/share/nmap/nselib/mysql.lua
/usr/share/nmap/nselib/data/mysql-cis.audit
/usr/share/nmap/scripts/mysql-audit.nse
/usr/share/nmap/scripts/mysql-brute.nse
/usr/share/nmap/scripts/mysql-databases.nse
/usr/share/nmap/scripts/mysql-dump-hashes.nse
/usr/share/nmap/scripts/mysql-empty-password.nse
/usr/share/nmap/scripts/mysql-enum.nse
/usr/share/nmap/scripts/mysql-info.nse
/usr/share/nmap/scripts/mysql-query.nse
/usr/share/nmap/scripts/mysql-users.nse
/usr/share/nmap/scripts/mysql-variables.nse
/usr/share/nmap/scripts/mysql-vuln-cve2012-2122.nse

When I type in the terminal, which mysql

No output is there.

When I type in the terminal,

mysql -u root -p

The output is,

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Is the MySQL is installed in the OS and if not how do I install?

Update:

As it was suggested, the MySQL server was not started. So, I start the server with the command,

sudo /etc/init.d/mysql start

The output is provided below,

[....] Starting mysql (via systemctl): mysql.service
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
 failed!

It error was suggest to look for more detailed informations with associated commands.

I type the terminal,

sudo systemctl status mysql.service

I get the output provided,

● mysql.service - LSB: Start and stop the mysql database server daemon
   Loaded: loaded (/etc/init.d/mysql)
   Active: failed (Result: exit-code) since Sun 2017-12-17 21:10:21 +06; 1min 10s ago
  Process: 28321 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

Dec 17 21:09:50 debian8 systemd[1]: Starting LSB: Start and stop the mysql .....
Dec 17 21:10:21 debian8 /etc/init.d/mysql[29152]: 0 processes alive and '/usr...
Dec 17 21:10:21 debian8 /etc/init.d/mysql[29152]: [61B blob data]
Dec 17 21:10:21 debian8 /etc/init.d/mysql[29152]: error: 'Can't connect to lo...
Dec 17 21:10:21 debian8 /etc/init.d/mysql[29152]: Check that mysqld is runnin...
Dec 17 21:10:21 debian8 /etc/init.d/mysql[29152]: 
Dec 17 21:10:21 debian8 mysql[28321]: Starting MySQL database server: mysql...d!
Dec 17 21:10:21 debian8 systemd[1]: mysql.service: control process exited, ...=1
Dec 17 21:10:21 debian8 systemd[1]: Failed to start LSB: Start and stop the...n.
Dec 17 21:10:21 debian8 systemd[1]: Unit mysql.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.

Secondly, I type the command for the journalctl provided below,

sudo journalctl -xn

The outout is,

-- Logs begin at Sun 2017-12-17 10:33:35 +06, end at Sun 2017-12-17 21:12:02 +06
Dec 17 21:10:21 debian8 mysql[28321]: Starting MySQL database server: mysqld . .
Dec 17 21:10:21 debian8 systemd[1]: mysql.service: control process exited, code=
Dec 17 21:10:21 debian8 systemd[1]: Failed to start LSB: Start and stop the mysq
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has failed.
-- 
-- The result is failed.
Dec 17 21:10:21 debian8 systemd[1]: Unit mysql.service entered failed state.
Dec 17 21:10:21 debian8 sudo[28307]: pam_unix(sudo:session): session closed for 
Dec 17 21:11:32 debian8 sudo[29437]: chaklader : TTY=pts/0 ; PWD=/home/chaklader
Dec 17 21:11:32 debian8 sudo[29437]: pam_unix(sudo:session): session opened for 
Dec 17 21:11:32 debian8 sudo[29437]: pam_unix(sudo:session): session closed for 
Dec 17 21:12:02 debian8 sudo[29539]: chaklader : TTY=pts/0 ; PWD=/home/chaklader
Dec 17 21:12:02 debian8 sudo[29539]: pam_unix(sudo:session): session opened for 
lines 1-18/18 (END)

So, basically, the first thing to do is to run the MySQL server properly.

I have also tried to run the server like,

sudo systemctl start mysql.serivce

The output provided,

Failed to start mysql.serivce.service: Unit mysql.serivce.service failed to load: No such file or directory.

What steps do I need to take for that?

Note:

As asked in the comment, at the time I execute the command,

sudo systemctl status mysql.service -l

I get the output like,

● mysql.service - LSB: Start and stop the mysql database server daemon
   Loaded: loaded (/etc/init.d/mysql)
   Active: failed (Result: exit-code) since Sun 2017-12-17 21:10:21 +06; 14min ago
  Process: 28321 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

Dec 17 21:09:50 debian8 systemd[1]: Starting LSB: Start and stop the mysql database server daemon...
Dec 17 21:10:21 debian8 /etc/init.d/mysql[29152]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
Dec 17 21:10:21 debian8 /etc/init.d/mysql[29152]: [61B blob data]
Dec 17 21:10:21 debian8 /etc/init.d/mysql[29152]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Dec 17 21:10:21 debian8 /etc/init.d/mysql[29152]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
Dec 17 21:10:21 debian8 /etc/init.d/mysql[29152]: 
Dec 17 21:10:21 debian8 mysql[28321]: Starting MySQL database server: mysqld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!
Dec 17 21:10:21 debian8 systemd[1]: mysql.service: control process exited, code=exited status=1
Dec 17 21:10:21 debian8 systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
Dec 17 21:10:21 debian8 systemd[1]: Unit mysql.service entered failed state.

What I primarily need to do is to migarte a database with the command,

/home/cx-components/cx-admin/app/console doctrine:migrations:migrate

I get the output like,

                    Application Migrations                    

  [PDOException]                                                             
  SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)  

doctrine:migrations:migrate [--write-sql] [--dry-run] [--query-time] [--configuration[="..."]] [--db-configuration[="..."]] [--db="..."] [--em="..."] [version]

What is the issue here?

As mentioned in the comment, I corrected the typo and run the command again, sudo systemctl start mysql.service

The output is here,

Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
  • Perhaps try following an install guide like this one: linode.com/docs/databases/mysql/… – Jesse_b Dec 17 '17 at 15:05
  • 1
    Please run sudo systemctl status mysql.service -l, that is, add the -l flag to see the ellipsized parts (all the ...) in full. – janos Dec 17 '17 at 15:23
  • I see. Unfortunately it doesn't show anything interesting. Try to find the logs. It might be somewhere in /var/log/mysql (I don't have a Debian around to verify the exact location) – janos Dec 17 '17 at 15:30
  • 1
    @roaima Thanks for catching out. It still hasn't started and provided the clues for detailed error stacks. – Arefe Dec 17 '17 at 16:16
  • anyone knows how do I connect the MySQL server on '127.0.0.1'? – Arefe Dec 17 '17 at 16:19
2

Based on the output of sudo dpkg --get-selections | grep mysql, MySQL (both the client tools and the server) are installed.

The error message you get when running mysql suggests that the MySQL service is not running. You can start it with:

sudo service mysql start
# or: sudo systemctl start mysql
  • hello, its good to know the client and the server both are installed. I tried to run the server as mentioned and it failed. I have provided the detailed error messages in the updated answer. – Arefe Dec 17 '17 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.