Even if I try mysql-u root with mysql, I get an error, so I want to solve it.

Asked 2 years ago, Updated 2 years ago, 47 views

What do you want to solve

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

Problems/errors encountered

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

# 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).

What I tried myself

Enter mysql-u root to

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

The error occurred

I thought mysql's server might not be working, but

 d dictation_app git: (master) my mysql.server start 
Starting MySQL
 * 
d 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 authorization
rm: '/var/run/mysqld/mysqld.pid' cannot be deleted: No authorization
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

The error has occurred as shown in .If you grant permission as instructed by the error,

 d 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: '/var/run/mysqld/mysqld.pid' cannot be deleted: No authorization
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

cat:/var/run/mysqld/mysqld.pid—Not authorized, but just disappeared.I was instructed to delete the file manually, so /var/run/mysqld/mysqld.pid.
Remove and try again mysql.server start

 d dictation_app git: (master) my 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).

Now to see if mysql is working

 ddiction_app git: (master) s 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 again.

 d dictation_app git: (master) my mysql-u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)

Also, the current state is

 ddiction_app git: (master) s 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
     CGgroup: /system.slice/mysql.service
             --23590/usr/sbin/mysqld

 February 01 14:21:54 sense-iy-CFSZ5-3systemd[1]: Starting MySQL Community Server >
 February 0114:21:55 sense-iy-CFSZ5-3systemd[1]: Started MySQL Community Service >


d dictation_app git: (master) p psaux | grep mysql
mysql235900.34.7 2269384 383224 ?Ssl14:210:35/usr/sbin/mysqld
sense_iy294650.0 0.0 18720 2464 pts/0 S+16:500:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=.bzr --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idsqir= --myoux.dir.dirir

Now, I decided to create the pid file again by referring to other sites

 sudo touch sense-iy-CFSZ5-3.pid

Then change permissions

#For some reason, if you follow the instructions on the reference site, you will get an error.
my mysqld sudo chown-R_mysql:_mysql var/run/mysql                  
[sudo] sense_iy password: 
chown: Incorrect customization: `_mysql:_mysql'

# I turned off the underbar and it worked, but I don't know if it's right.I'm not sure why I use this command to change my permissions, but I tried it for now.The part that was originally root became mysql.
my mysqld sudo chown-R mysql: mysql/var/run/mysqld
my mysqldls-l sense-iy-CFSZ5-3.pid 

-rw-r--r--1mysql mysql 0 February 11 7:02 sense-iy-CFSZ5-3.pid

However, mysql-u root does not change.I thought it might be a little strange to make it again even though I deleted it according to the instructions, so I looked at various sites after that, but there were so many articles related to mariaDB (I have never installed it) that I couldn't proceed.

Other

·I am using ubuntu 20.04.
·I tried reinstalling and rebooting.
·It worked well when I was using sqlite3.Currently uninstalling.
·Originally, I changed it to mysql in the directory where I was using sqlite3, so I remade it from zero.So I don't think sqlite3 has anything to do with it.
·There were not many ubuntu articles, so it is difficult to gather information, so I am referring to other OS articles for now.
·Mysql is up to date.
·For some reason, sudo mysql.server start
sudo:mysql.server:command not found
That's what happens.
·It seems that mysql itself is activated.
·I'm a beginner, so I might be doing something strange.

If you have any advice, please let me know.Thank you for your cooperation.

Add

Error

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

So I did it.However, when I searched for this command, I only got two hits, so I don't know what kind of command it is, but I just tried it.

 ddiction_app git: (master) s 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/mysql
2022-02-01T10:47:48.265914Z mysqld_safe mysqld from pid file/var/run/mysqld/mysqld.pid ended

There was no change.

Add

I used this site for mysql reference.
https://self-development.info/ubuntu-20-04%E3%81%AB%E6%9C%80%E6%96%B0%E7%89%88%E3%81%AEmysql-8-0%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB of
I followed this site until the end, but at first I couldn't figure out how to resolve this error at all, so I couldn't really understand it after installing it and fiddling with various settings → I repeatedly deleted it and reinstalled it.And when I downloaded mysql for the first time, I was installing it by looking at various descriptions and executing many of the contents.So I didn't install it for reference only on one site.However, https://qiita.com/hkusu/items/cda3e8461e7a46ecf25d
In a similar way to this article

$brew update
$ brew install mysql

There is no doubt that you used this command.Perhaps the method you installed at this time is the cause of the error.

mysql ubuntu

2022-09-29 22:29

1 Answers

I managed to resolve the error.It seems that the problem was that I installed mysql again in a different way, even though I installed mysql in Brew (maybe I installed two?).I deleted all mysql except brew and it worked well.I forgot that I installed mysql at the beginning → I did not know how to copy the settings properly → and reinstalled it in a different way.Thank you for your valuable time this time.


2022-09-29 22:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.