Home>

What you want to solve

I can't solve the error in mysql, so I want to solve it.

Problems /errors occurring

# 1st
ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/tmp/mysql.sock' (111)
#The second
Starting MySQL
./home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
/home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
/home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 1: eval: cannot create /var/log/mysql/error.log: Permission denied
/home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
 * The server quit without updating PID file (/var/run/mysqld/mysqld.pid).

I tried it myself

mysql -u rootWhen you enter

ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/tmp/mysql.sock' (111)

error occurs

I thought that the mysql server wasn't working, but

➜ dictation_app git: (master) ✗ mysql.server start
Starting MySQL
 *
➜ dictation_app git: (master) ✗ /home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
cat: /var/run/mysqld/mysqld.pid: No permission
rm: Unable to delete'/var/run/mysqld/mysqld.pid': No permission
2022-02-01T05: 41: 01.994696Z mysqld_safe Fatal error: Can't remove the pid file:
/var/run/mysqld/mysqld.pid.
Please remove the file manually and start /home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe again;
mysqld daemon not started
/home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
I got an error like

. If you give permissions as instructed by the error

➜ dictation_app git: (master) ✗ /home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
rm: Unable to delete'/var/run/mysqld/mysqld.pid': No permission
2022-02-01T05: 54: 09.215517Z mysqld_safe Fatal error: Can't remove the pid file:
/var/run/mysqld/mysqld.pid.
Please remove the file manually and start /home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe again;
mysqld daemon not started
/home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
Like

cat: /var/run/mysqld/mysqld.pid: No permission but just disappeared. I was instructed to manually delete the file, so /var/run/mysqld/mysqld.pid.
And then mysql.server start again

➜ dictation_app git: (master) ✗ mysql.server start
Starting MySQL
./home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
/home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
/home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 1: eval: cannot create /var/log/mysql/error.log: Permission denied
/home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe: 144: cannot create /var/log/mysql/error.log: Permission denied
 * The server quit without updating PID file (/var/run/mysqld/mysqld.pid).

Here to check if mysql is running

➜ dictation_app git: (master) ✗ sudo systemctl enable --now mysql
Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib /systemd /systemd-sysv-install enable mysql

It doesn't work even if I try it again.

➜ dictation_app git: (master) ✗ mysql -u rootERROR 2002 (HY000): Can't connect to local MySQL server through socket'/tmp/mysql.sock' (111) 

Also, the current state is

➜ dictation_app git: (master) ✗ systemctl status mysql.service
● mysql.service-MySQL Community Server
     Loaded: loaded (8 ;; file: //sense-iy-CFSZ5-3/lib/systemd/system/mysql.s >
     Active: active (running) since Tue 2022-02-01 14:21:55 JST; 2h 17min >
       Docs: 8 ;; man: mysqld (8) ^ Gman: mysqld (8) 8 ;; ^ G
             8 ;; http://dev.mysql.com/doc/refman/en/using-systemd.html^Ghtt>
   Main PID: 23590 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 9330)
     Memory: 343.5M
     CGroup: /system.slice/mysql.service
             └─23590 /usr /sbin /mysqld
 February 01 14:21:54 sense-iy-CFSZ5-3 systemd [1]: Starting MySQL Community Ser >
 February 01 14:21:55 sense-iy-CFSZ5-3 systemd [1]: Started MySQL Community Serv >
➜ dictation_app git: (master) ✗ ps aux | grep mysql
mysql 23590 0.3 4.7 2269384 383224? Ssl 14:21 0:35 /usr /sbin /mysqld
sense_iy 29465 0.0 0.0 18720 2464 pts /0 S + 16:50 0:00 grep --color= auto --exclude-dir= .bzr --exclude-dir= CVS --exclude-dir= .git --exclude-dir= .hg --exclude-dir= .svn --exclude-dir= .idea --exclude-dir= .tox mysql

Here, I decided to create a pid file again with reference to other sites.

sudo touch sense-iy-CFSZ5-3.pid

Then change the authority

# For some reason, if you do as written on the referenced site, an error will occur.
➜ mysqld sudo chown -R _mysql: _mysql var /run /mysql
[sudo] sense_iy password:
chown: Invalid user specification: `_mysql: _mysql'
# I erased the underscore and it worked, but I'm not sure if it fits. I'm not sure why this command changes the permissions, but I tried running it for the time being. The part that was originally root is now mysql.
➜ mysqld sudo chown -R mysql: mysql /var /run /mysqld
➜ mysqld ls -l sense-iy-CFSZ5-3.pid
-rw-r--r--1 mysql mysql 0 February 1 17:02 sense-iy-CFSZ5-3.pid

But mysql -u root doesn't change. In the first place, I deleted it according to the instructions, but I thought that it would be a little strange to make it again, but after that I looked at various sites, but there are many articles related to mariaDB (I have never installed it) and I do not know which one is effective. , I can't proceed because I'm stuck here.

Others

・ I am using ubuntu 20.04.
-I tried reinstalling and restarting.
・ It worked fine when I was using sqlite3. I'm currently uninstalling.
-Originally, I changed to mysql in the directory while using sqlite3, so I thought it was the cause, so I recreated it from 0. So I don't think sqlite3 is relevant.
・ Since there weren't many articles on ubuntu, it was difficult to collect information, so I'm referring to articles on other OSs for the time being.
・ Mysql is the latest.
・ For some reason, when I do sudo mysql.server start,
sudo: mysql.server: command not found
It will become.
-It seems that mysql itself is running.
・ Because I am a beginner, I may be doing strange operations.

If you have any advice, please let me know. I look forward to working with you.

Addition

In error

Please remove the file manually and start /home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe again;
Since it was

, execute it. However, even if I searched with this command, only 2 hits were found, so I don't know what kind of command it is, but I tried it for the time being.

➜ dictation_app git: (master) ✗ sudo /home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.28/bin/mysqld_safe
2022-02-01T10: 46: 07.812058Z mysqld_safe Logging to'/var/log/mysql/error.log'.2022-02-01T10: 46: 07.847246Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql2022-02-01T10: 47: 48.265914Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

There was no change.

Addition

mysql was done with reference to this site.

I went according to this site until the end. However, at first, I couldn't find a solution to this error at all, so I installed it and messed with various settings to make it difficult to understand. And when I downloaded mysql for the first time, I installed it by looking at various descriptions and executing the contents written a lot. So I didn't install it by referring to only one site. However, https://qiita.com/hkusu/items/cda3e8461e7a46ecf25d
In a similar way to this article

$ brew update
$ brew install mysql

I'm sure I used this command. Perhaps the method installed at this time is the cause of the error.

It looks like MySQL installed with linuxbrew, but let's describe the procedure.

endymion2022-02-11 21:39:48
  • Answer # 1

    I managed to resolve the error. Apparently the problem was that I had mysql installed with brew, but had mysql installed again in a different way (perhaps I had two installed?). I removed all mysql except brew and it worked fine. At the beginning, I forgot to install it with brew because there was a time when I installed mysql → copy and paste the settings properly → I didn't understand and reinstalled it in another way. Thank you for taking the time to spare this time.

  • Answer # 2

    I managed to resolve the error. Apparently the problem was that I had mysql installed with brew, but had mysql installed again in a different way (perhaps I had two installed?). I removed all mysql except brew and it worked fine. At the beginning, I forgot to install it with brew because there was a time when I installed mysql → copy and paste the settings properly → I didn't understand and reinstalled it in another way. Thank you for taking the time to spare this time.