Sou novo no Linux, recentemente instalei um sistema operacional Debian Jessie (8) e preciso trabalhar com o MySQL. O nome do host é
hostname -f
Imprime, debian8
Quando eu digito no terminal,
sudo dpkg --get-selections | grep mysql
Eu recebo a saída de volta,
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
Quando eu digito no terminal,
sudo apt-cache show mysql
A saída é
N: Unable to locate package mysql
E: No packages found
chaklader@debian8:/home/cx-components$
Quando eu digito no terminal,
locate mysql
A saída é
/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
Quando eu digito no terminal,
which mysql
Nenhuma saída está lá.
Quando eu digito no terminal,
mysql -u root -p
A saída é
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
O MySQL está instalado no sistema operacional e, se não, como eu instalo?
Atualização:
Como foi sugerido, o servidor MySQL não foi iniciado. Então, eu inicio o servidor com o comando
sudo /etc/init.d/mysql start
A saída é fornecida abaixo,
[....] Starting mysql (via systemctl): mysql.service
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
failed!
Foi sugerido erro para procurar informações mais detalhadas com comandos associados.
eu digito o terminal,
sudo systemctl status mysql.service
Eu recebo a saída fornecida,
● 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.
Em segundo lugar, eu digito o comando para o journalctl
fornecido abaixo,
sudo journalctl -xn
O outout é,
-- 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)
Então, basicamente, a primeira coisa a fazer é executar o servidor MySQL corretamente.
Eu também tentei executar o servidor como
sudo systemctl start mysql.serivce
A saída fornecida,
Failed to start mysql.serivce.service: Unit mysql.serivce.service failed to load: No such file or directory.
Quais etapas eu preciso dar para isso?
Note:
Conforme solicitado no comentário, no momento em que executo o comando,
sudo systemctl status mysql.service -l
Eu obtenho a saída como
● 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.
O que eu preciso fazer é migrar um banco de dados com o comando
/home/cx-components/cx-admin/app/console doctrine:migrations:migrate
Eu obtenho a saída como
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]
Qual é o problema aqui?
Como mencionado no comentário, corrigi o erro e executei o comando novamente,
sudo systemctl start mysql.service
A saída está aqui,
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.