Securing the MySQL server deployment.
Enter password for user root:
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
systemctl status mysql
اگر این طور نبود با دستور زیر، سرویس رو اجرا کنید:sudo systemctl start mysql
alireza@OptiPlex-5090:~$ systemctl status mysql
○ mysql.service
Loaded: masked (Reason: Unit mysql.service is masked.)
Active: inactive (dead)
alireza@OptiPlex-5090:~$ sudo systemctl start mysql
[sudo] password for alireza:
Failed to start mysql.service: Unit mysql.service is masked.
sudo systemctl unmask mysql
sudo systemctl start mysql
alireza@OptiPlex-5090:~$ sudo systemctl unmask mysql
[sudo] password for alireza:
Removed /etc/systemd/system/mysql.service.
alireza@OptiPlex-5090:~$ sudo systemctl start mysql
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details.
sudo systemctl status mysql.service
× mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:>
Active: failed (Result: exit-code) since Fri 2023-03-24 10:14:23 +03; 5min>
Process: 2389 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=e>
CPU: 1ms
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Scheduled restart job,>
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Stopped MySQL Community Server.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Start request repeated>
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Failed with result 'ex>
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Failed to start MySQL Community Serve>
lines 1-11/11 (END)
sudo journalctl -xeu mysql.service
[sudo] password for alireza:
░░ Automatic restarting of the unit mysql.service has been scheduled, as the re>
░░ the configured Restart= setting for the unit.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Stopped MySQL Community Server.
░░ Subject: A stop job for unit mysql.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A stop job for unit mysql.service has finished.
░░
░░ The job identifier is 2312 and the job result is done.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Start request repeated>
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Failed with result 'ex>
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit mysql.service has entered the 'failed' state with result 'exit-code>
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Failed to start MySQL Community Serve>
░░ Subject: A start job for unit mysql.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit mysql.service has finished with a failure.
░░
░░ The job identifier is 2312 and the job result is failed.
lines 601-625/625 (END)
░░ Automatic restarting of the unit mysql.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Stopped MySQL Community Server.
░░ Subject: A stop job for unit mysql.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A stop job for unit mysql.service has finished.
░░
░░ The job identifier is 2312 and the job result is done.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Start request repeated too quickly.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit mysql.service has entered the 'failed' state with result 'exit-code'.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Failed to start MySQL Community Server.
░░ Subject: A start job for unit mysql.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit mysql.service has finished with a failure.
░░
░░ The job identifier is 2312 and the job result is failed.
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
lines 601-625/625 (END)
░░ Automatic restarting of the unit mysql.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Stopped MySQL Community Server.
░░ Subject: A stop job for unit mysql.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A stop job for unit mysql.service has finished.
░░
░░ The job identifier is 2312 and the job result is done.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Start request repeated too quickly.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit mysql.service has entered the 'failed' state with result 'exit-code'.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Failed to start MySQL Community Server.
░░ Subject: A start job for unit mysql.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit mysql.service has finished with a failure.
░░
░░ The job identifier is 2312 and the job result is failed.
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
lines 601-625/625 (END)
alireza@OptiPlex-5090:~$ sudo df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 6.3G 2.7M 6.3G 1% /run
/dev/nvme0n1p3 912G 252G 614G 30% /
tmpfs 32G 35M 32G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
/dev/nvme0n1p1 239M 29M 210M 12% /boot/efi
tmpfs 6.3G 8.5M 6.3G 1% /run/user/1001
alireza@OptiPlex-5090:~$ sudo apt-get --purge remove mysql
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package mysql
alireza@OptiPlex-5090:~$ sudo apt purge mysql-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libcgi-fast-perl libcgi-pm-perl libfcgi-bin libfcgi-perl libfcgi0ldbl
libhtml-template-perl libmecab2 libprotobuf-lite23 mecab-ipadic
mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0
mysql-server-8.0 mysql-server-core-8.0
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
mysql-server*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 35.8 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 418507 files and directories currently installed.)
Removing mysql-server (8.0.32-0ubuntu0.22.04.2) ...
alireza@OptiPlex-5090:~$ sudo rm -r /etc/mysql
alireza@OptiPlex-5090:~$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
mysql-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/9,458 B of archives.
After this operation, 35.8 kB of additional disk space will be used.
Selecting previously unselected package mysql-server.
(Reading database ... 418505 files and directories currently installed.)
Preparing to unpack .../mysql-server_8.0.32-0ubuntu0.22.04.2_all.deb ...
Unpacking mysql-server (8.0.32-0ubuntu0.22.04.2) ...
Setting up mysql-server (8.0.32-0ubuntu0.22.04.2) ...
alireza@OptiPlex-5090:~$ sudo mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
systemctl status mysql
sudo journalctl -exu mysql
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2023-03-24 10:14:23 +03; 3h 35min ago
Process: 2389 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
CPU: 1ms
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Stopped MySQL Community Server.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Start request repeated too quickly.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Failed to start MySQL Community Server.
Automatic restarting of the unit mysql.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Stopped MySQL Community Server.
░░ Subject: A stop job for unit mysql.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A stop job for unit mysql.service has finished.
░░
░░ The job identifier is 2312 and the job result is done.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Start request repeated too quickly.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: mysql.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit mysql.service has entered the 'failed' state with result 'exit-code'.
Mar 24 10:14:23 OptiPlex-5090 systemd[1]: Failed to start MySQL Community Server.
░░ Subject: A start job for unit mysql.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit mysql.service has finished with a failure.
░░
░░ The job identifier is 2312 and the job result is failed.