Mysql不是单独运行的,而是在lampp/xampp中运行

Mysql不是单独运行的,而是在lampp/xampp中运行

我刚刚开始在 ubuntu 上使用核心 php 和 laravel 框架进行 web 开发。我已经安装了 php 和所有依赖项,但是mysql 不能单独工作,但它在 lampp 内部工作

所以我开始给出以下命令

mysql -u 根 -p

我得到了以下响应(仅运行“mysql”和“sudo mysql”相同)

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

另外,当我进入 /var/run 时,没有名为 mysqld 的文件夹

cd /var/run/mysqld
bash: cd: /var/run/mysqld: No such file or directory

也看看这个

cd /var/run 
aq@DevilsBook:/var/run$ ls
acpid.pid     console-setup  dhclient-wlo1.pid  initctl      mount           rsyslogd.pid       sudo        user
acpid.socket  crond.pid      dmeventd-client    initramfs    network         sendsigs.omit.d    systemd     utmp
alsa          crond.reboot   dmeventd-server    lock         NetworkManager  shm                thermald    uuidd
apache2       cryptsetup     fsck               log          php             snapd-snap.socket  tmpfiles.d  wpa_supplicant
avahi-daemon  cups           gdm3               lvm          plymouth        snapd.socket       udev
blkid         dbus           gdm3.pid           lvmetad.pid  pppconfig       spice-vdagentd     udisks2

除此之外,/var/lib 中还有一个名为 mysql 和 mysql-upgrade 的文件夹。

然后我尝试了服务 mysql 启动命令,花费了很多时间

sudo service mysql status
[sudo] password for aq: 
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enable
   Active: inactive (dead)

[1]+  Stopped                 sudo service mysql status

并运行相同的命令,但没有 sudo我得到了

Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.

之后我明白了systemctl 状态 mysql.service结果是

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enable
   Active: failed (Result: exit-code) since Tue 2019-01-15 01:04:13 PKT; 28s ago
  Process: 3359 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exit

جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Service hold-off time ov
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Scheduled restart job, r
جنوری 15 01:04:13 DevilsBook systemd[1]: Stopped MySQL Community Server.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Start request repeated t
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Failed with result 'exit
جنوری 15 01:04:13 DevilsBook systemd[1]: Failed to start MySQL Community Server.
lines 1-11/11 (END)...skipping...
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2019-01-15 01:04:13 PKT; 28s ago
  Process: 3359 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)

جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
جنوری 15 01:04:13 DevilsBook systemd[1]: Stopped MySQL Community Server.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Start request repeated too quickly.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Failed with result 'exit-code'.
جنوری 15 01:04:13 DevilsBook systemd[1]: Failed to start MySQL Community Server.
~
~
~
~
~
~
~



[2]+  Stopped                 systemctl status mysql.service

最后我跑了journalctl-xe

جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Automatic restarting of the unit mysql.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
جنوری 15 01:04:13 DevilsBook systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has finished shutting down.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Start request repeated too quickly.
جنوری 15 01:04:13 DevilsBook systemd[1]: mysql.service: Failed with result 'exit-code'.
جنوری 15 01:04:13 DevilsBook systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has failed.
-- 
-- The result is RESULT.
جنوری 15 01:05:29 DevilsBook systemd[1]: Starting Cleanup of Temporary Directories...
-- Subject: Unit systemd-tmpfiles-clean.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit systemd-tmpfiles-clean.service has begun starting up.
جنوری 15 01:05:30 DevilsBook systemd[1]: Started Cleanup of Temporary Directories.
-- Subject: Unit systemd-tmpfiles-clean.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit systemd-tmpfiles-clean.service has finished starting up.
-- 
-- The start-up result is RESULT.

尽管 mysql 在 lamp 中工作,但可以看到 lampp 运行的结果sudo /opt/lampp/lampp 启动

aq@DevilsBook:~$ sudo /opt/lampp/lampp start
[sudo] password for aq: 
Starting XAMPP for Linux 7.2.13-0...
XAMPP: Starting Apache...fail.
XAMPP:  Another web server is already running.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.

我如何找到文件夹和包来消除这个问题?

答案1

答案来自 ->>https://www.youtube.com/watch?v=qr-t8ksYO78

转到 my.cnf 文件,请注意,您将找到多个 my.cnf 文件,我必须查看所有文件才能找到这个->

# The MySQL server
[mysqld]
user = mysql
port=3306
socket      = /opt/lampp/var/mysql/mysql.sock

复制路径并像这样写入 ->

mysql -u root -p --socket=/opt/lampp/var/mysql/mysql.sock 

谢谢

相关内容