title: mysql踩坑
author: lensfrex
date: 2022-04-04 10:33:10
tags:
---
sudo /usr/bin/mysqld_safe &
het@iZbp1hzgpnnozttvvbihj7Z:/$ sudo find -name mysql.sock
find: ‘./proc/277011’: No such file or directory
het@iZbp1hzgpnnozttvvbihj7Z:/$ sudo find -name mysqladmincd^C
het@iZbp1hzgpnnozttvvbihj7Z:/$ cd etc/mysql
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql$ ls
conf.d  debian.cnf  debian-start  my.cnf  my.cnf.fallback  mysql.cnf  mysql.conf.d
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql$ cd conf.d
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/conf.d$ ls
mysql.cnf  mysqldump.cnf
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/conf.d$ cd ../
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql$ la
-bash: la: command not found
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql$ ls
conf.d  debian.cnf  debian-start  my.cnf  my.cnf.fallback  mysql.cnf  mysql.conf.d
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql$ cd mysql.conf.d
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ ls
mysql.cnf  mysqld.cnf
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ sudo nvim mysql.cnf
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ sudo nvim mysqld.cnf
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ sudo service mysql start
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ sudo nvim mysqld.cnf
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ ls /var/run/mysqld/
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ sudo nvim mysqld.cnf
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ nvim /var/log/mysql/error.log
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ ls /var/log/mysql/
ls: cannot open directory '/var/log/mysql/': Permission denied
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ sudo nvim /var/log/mysql/error.log
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ sudo nvim mysqld.cnf
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ sudo service mysql start

het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$
het@iZbp1hzgpnnozttvvbihj7Z:/etc/mysql/mysql.conf.d$ cd /etc/init.d
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ ls
aegis         console-setup.sh  hddtemp            netfilter-persistent  pppd-dns                     ssh
apparmor      cron              hwclock.sh         network-manager       procps                       status-server
apport        cups              irqbalance         nginx-debug           pulseaudio-enable-autospawn  sysstat
atd           cups-browsed      keyboard-setup.sh  ntp                   pureftpd                     udev
avahi-daemon  dbus              kmod               php7.4-fpm            resolvconf                   ufw
bluetooth     fio               lightdm            plymouth              rsync                        uuidd
boinc-client  gdm3              lm-sensors         plymouth-log          rsyslog                      vsftpd
chrony        grub-common       mysql              postfix               screen-cleanup               x11-common
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ cd mysql
-bash: cd: mysql: Not a directory
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ nvim mysql
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ sudo mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ sudo ./mysql
Usage: /etc/init.d/mysql start|stop|restart|reload|force-reload|status
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ sudo ./mysql start
Starting mysql (via systemctl): mysql.service.
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ sudo netstat -lapn | grep mysql
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ safe_mysqld&
[1] 285411
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ -bash: safe_mysqld: command not found

[1]+  Exit 127                safe_mysqld
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ safe_mysqld&
[1] 285486
-bash: safe_mysqld: command not found
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ ^C
[1]+  Exit 127                safe_mysqld
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ safe_mysqld
-bash: safe_mysqld: command not found
het@iZbp1hzgpnnozttvvbihj7Z:/etc/init.d$ cd /
het@iZbp1hzgpnnozttvvbihj7Z:/$ sudo find -name mysqld_safe
./usr/bin/mysqld_safe
het@iZbp1hzgpnnozttvvbihj7Z:/$ /usr/bin/mysqld_safe &
[1] 286015
het@iZbp1hzgpnnozttvvbihj7Z:/$ /usr/bin/mysqld_safe: 653: cannot create /var/log/mysql/error.log: Permission denied
Logging to '/var/log/mysql/error.log'.
2022-04-04T02:31:05.698613Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
/usr/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
/usr/bin/mysqld_safe: 1: eval: cannot create /var/log/mysql/error.log: Permission denied
/usr/bin/mysqld_safe: 916: cannot create /var/log/mysql/error.log: Permission denied
rm: cannot remove '/var/lib/mysql/iZbp1hzgpnnozttvvbihj7Z.pid.shutdown': Permission denied
2022-04-04T02:31:05.715768Z mysqld_safe mysqld from pid file /var/lib/mysql/iZbp1hzgpnnozttvvbihj7Z.pid ended
/usr/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
^C
[1]+  Done                    /usr/bin/mysqld_safe
het@iZbp1hzgpnnozttvvbihj7Z:/$ sudo /usr/bin/mysqld_safe &
[1] 286238
het@iZbp1hzgpnnozttvvbihj7Z:/$ 2022-04-04T02:31:13.353776Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2022-04-04T02:31:13.384979Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

het@iZbp1hzgpnnozttvvbihj7Z:/$ sudo netstat -lapn | grep mysql
tcp        0      0 127.0.0.1:33060         0.0.0.0:*               LISTEN      286417/mysqld
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      286417/mysqld
unix  2      [ ACC ]     STREAM     LISTENING     256439674 286417/mysqld        /var/run/mysqld/mysqlx.sock
unix  2      [ ACC ]     STREAM     LISTENING     256439696 286417/mysqld        /var/run/mysqld/mysqld.sock
het@iZbp1hzgpnnozttvvbihj7Z:/$ sudo nginx
het@iZbp1hzgpnnozttvvbihj7Z:/$
