Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)
Asked Answered
C

45

462

I am having a big problem trying to connect to mysql. When I run:

/usr/local/mysql/bin/mysql start

I have the following error :

Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)

I do have mysql.sock under the /var/mysql directory.

In /etc/my.cnf I have:

[client]
port=3306
socket=/var/mysql/mysql.sock

[mysqld]
port=3306
socket=/var/mysql/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M

and in /etc/php.ini I have :

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /var/mysql/mysql.sock

I have restarted apache using sudo /opt/local/apache2/bin/apachectl restart

But I still have the error.

Otherwise, I don't know if that's relevant but when I do mysql_config --sockets I get

--socket         [/tmp/mysql.sock]
Cranky answered 21/3, 2011 at 10:33 Comment(14)
Is MySQL running?Mccray
I'd supplement @David, you should look at the MySQL log to see if the server is actually running or if it has crashed/is not ready to accept connections.Aviles
No, mysql is not running, i have the "Can't connect....."errorCranky
That certainly explains the error in trying to connect to it. How, as @Aviles mentioned, is there anything in MySQL's logs (try /var/log/mysql or somewhere around there) which indicates why it isn't running? Do you get an error when you try to start it?Mccray
I was getting the same error, but in my case, I found out mysql wouldn't start because the disk was 100% full. /var/log/mysqld.log was helpful.Yah
the reason they are asking if it is running, i presume, is because the socket is made when the service starts. i installed mysql, but never started the service, so the .sock file doesn't exist. type service mysqld start if you just installed. hthSpecialism
Isn't the error here from the client? It would be good for that to be clarified. After starting the service, then attempting to connect, got the error. In my case it was relevant which user I was, as well, because the fix I needed was the sudo chmod -R 755 /var/lib/mysql/ in the accepted answer. I did not get the error when I ran the client as root.Dawdle
Below answer of shimanyi sudo service mysql start saved meCoexist
This error occurred when I moved the default mysql datadir. I was able to get mysqld to start but couldn't get the client to start. Looking at how you set the [client] configs in my.cnf helped me solve the issue.Satori
I have similar problem. I my case the easy solution was to restart connection with MySQL Workbench via root user accountNeoarsphenamine
Same here @KirenSiva, after trying to go through every single top answer, I just had to start the service. Thought LAMPP started it for me.Tillandsia
If you cannot restart than check logs /var/log/mysql next. It will save you hours of your time. Error messages can be misleading, logs usually contain a lot more info.Feather
I don't know if this could help, I just restarted the entire machine, and the MySQL server is now running, lol.Plasticize
are you out of disk space? That can cause exactly this problem.Letdown
W
241

If your file my.cnf (usually in the /etc/mysql/ folder) is correctly configured with:

socket=/var/lib/mysql/mysql.sock

You can check if mysql is running with the following command:

mysqladmin -u root -p status

Try changing your permission to mysql folder. If you are working locally, you can try:

sudo chmod -R 755 /var/lib/mysql/

That solved it for me.

Weatherworn answered 10/11, 2011 at 19:8 Comment(10)
It helped me after I followed the steps above and restarted the mysqld service.Brickle
It would be best if you set the permissions to 755 so that only the directory owner can write to it.Caruthers
My problem was actually just that my storage volume for my web app had run out of space! Classic!Rosemaryrosemond
On my openSUSE 12.3, my.cnf is in /etc/.Punke
we should also change permission to /var/log/mysqld.log, ThanksAvruch
my.cnf could be in a different place, such as /etc/my.cnf in RedHat 7Stroboscope
My issue related to a time when I tried to install MySql 5.6 but has just now reared its head after some updates I think...Locket
It should be under [client] groupChemoprophylaxis
Thanks al lot only for me only a permission problemBedroll
had to add the configurationMariann
S
104

A quick workaround that worked for me: try using the local ip address (127.0.0.1) instead of 'localhost' in mysql_connect(). This "forces" php to connect through TCP/IP instead of a unix socket.

Sauer answered 1/12, 2011 at 10:18 Comment(9)
It worked... but why? Doesn't MySQL resolve localhost and get 127.0.0.1 anyway before even trying to connect?Postman
nope... when using localhost you aren't using an Internet Socket. You are using a IPC Socket. en.wikipedia.org/wiki/Unix_domain_socket . 127.0.0.1 is local loopback which means the request won't exit your machine but it will use TCP/IP thus being slower...Graycegrayheaded
Works for me too. I'm on ubuntu 14.04, hhvm and nginx.Grass
thanks. this works for me but it's not clear to me from the answer what the fix isEgon
This is also necessary when you connect to remote server through a ssh tunnelHewlett
Ok. it works, but there is no need to use this trick - TCP/IP can be simply forced by passing additional parameter for the connection: --protocol=tcp.Benedick
Great it works for me though I'm not using PHP. I was using zazler to connect mysqlDisproportion
This fixed it for me. It turns out when I connect to "localhost" it relies on the socket file. But when I explicitly set the database host to "127.0.0.1" it does not. Perhaps someone changed in my system when I installed latest updates.Lucylud
The same, similar issue is when connecting via command line client to a port forwarded from virtualbox or docker, when you use it without a host parameter, it will fail on socket, when you use it with an -H host parameter, and with 127.0.0.1 instead of localhost, it will succeed, mysql -h 127.0.0.1 instead of mysql -h localhostManzanares
I
101

Are you sure you installed MySQL as well as MySQL server?

For example to install MySQL server I'll use yum or apt to install both MySQL command line tool and the server:

yum -y install mysql mysql-server (or apt-get install mysql mysql-server)

Enable the MySQL service:

/sbin/chkconfig mysqld on

Start the MySQL server:

/sbin/service mysqld start

Afterwards set the MySQL root password:

mysqladmin -u root password 'new-password' (with the quotes)
Iceland answered 24/6, 2012 at 13:55 Comment(3)
I used homebrew and it worked like a charm: brew install mysqlAlwin
I had already installed the client, the command I needed was sudo apt-get install mysql-server then life was goodBanquet
Isn't the output Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38) from the client? It's the client trying and failing to connect, right? (I think the original question needs editing to clarify that).Dawdle
C
56

I got the following error:

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

Tried several ways and finally solved it through the following way:

sudo gksu gedit /etc/mysql/my.cnf

Modified:

#bind-address       = 127.0.0.1

to:

bind-address        = localhost

and restarted:

sudo /etc/init.d/mysql restart

It worked.

Cataplasm answered 14/7, 2012 at 11:37 Comment(1)
I had a similar issue; moved from ethernet (192.168.220.11) to wifi (192.168.220.12) but had bind-address hard-coded to ethernet IP. Changing to localhost fixed it.Appealing
M
38

Make sure you are running mysqld : /etc/init.d/mysql start

Microwatt answered 11/5, 2012 at 4:37 Comment(1)
Or sudo service mysql start|restart for Ubuntu.Staats
B
26

I got this error when I set cron job for my file. I changed the permissions of file to 777 but it still not worked for me. Finally I got the solution. May be it will be helpful for others.

Try with this command:

mysql -h 127.0.0.1 -P 3306 -u root -p

Remember that -h means host, -P means port and -p means password.

Bielefeld answered 1/12, 2016 at 14:52 Comment(5)
Forcing a connection over TCP/IP instead of using a socket is inefficient (and requires that you turn on localhost TCP/IP support in the server, as per this earlier answer). The accepted answer from 2011 is better: Configure the server so you can use a socket properly.Brough
-p does not mean port, it means password, you've confused it with -PBrough
This seems to be, more or less, a copy of this earlier answerBrough
For me it was just a matter of defining the correct host: mysql -h 127.0.0.1 -u root -pSchwerin
Thank you! I didn't have .sock file but helped me.Salomie
D
19

To prevent the problem from occurring, you must perform a graceful shutdown of the server from the command line rather than powering off the server.

shutdown -h now

This will stop the running services before powering down the machine.

Based on Centos, an additional method for getting it back up again when you run into this problem is to move mysql.sock:

mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak

service mysqld start

Restarting the service creates a new entry called mqsql.sock

Dentilabial answered 19/12, 2013 at 10:50 Comment(0)
C
15

As can be seen by the many answers here, there are lots of problems that can result in this error message when you start the MySQL service. The thing is, MySQL will generally tell you exactly what's wrong, if you just look in the appropriate log file.

For example, on Ubuntu, you should check /var/log/syslog. Since lots of other things might also be logging to this file, you probably want to use grep to look at mysql messages, and tail to look at only the most recent. All together, that might look like:

grep mysql /var/log/syslog | tail -50

Don't blindly make changes to your configuration because someone else said 'This worked for my system.' Figure out what is actually wrong with your system and you'll get a better result much faster.

Cotta answered 16/12, 2015 at 19:33 Comment(2)
+1 For taking a step back and pointing out something that many of the other answers fail to even consider - that actually seeing what the application might have reported as a problem is a much better approach than to blindly rush in and make changes which may not even be applicable...!Ashwin
Ah, so it's using the wrong .cnf. That explains it. Now I can stop trying random things and address the actual issue. Thanks.Stirk
A
13

Another workaround is to edit /etc/my.cnf and include host in the section [client]

 [client]
 #password       = your_password
 host            = 127.0.0.1
 port            = 3306
 socket          = /var/run/mysql/mysql.sock

And then restarting the mysql service.

This workaround was tested in: Server version: 5.5.25a-log Source distribution

Airlift answered 10/1, 2013 at 17:25 Comment(1)
adding the [client] section is recommended if not already in my.cnfJulejulee
H
11

Try with -h (host) and -P(port):

mysql -h 127.0.0.1 -P 3306 -u root -p

Hyacinth answered 19/6, 2015 at 12:33 Comment(0)
H
8

I had the same problem and it has been caused by an update of mysql drivers when mysql server was running. I fixed it just restarting both mysql and apache2:

sudo service mysql stop

sudo service mysql start

sudo service apache2 stop

sudo service apache2 start

Helm answered 20/1, 2013 at 18:8 Comment(1)
In my case, mysql wasn't running. I ran sudo service mysql start after running sudo service mysql status to verify it wasn't running.Frenulum
U
7

If everything worked just fine and you just started seeing this error, before you do anything else, make sure you're not out of disk space:

df -h

If the volume where the mysql.sock is being created is at 100% use, MySql won't be able to create it and this will be the cause of this error. All you need to do is delete something that's not needed, like old log files.

Urbas answered 29/7, 2014 at 18:5 Comment(0)
U
7
sudo service mysql start

This should serve you just fine. There could be a possibility that you changed some commands that affected the mysql configurations.

Unconscious answered 23/1, 2015 at 8:27 Comment(1)
or systemctl start mariadb.service in Fedora 22 or RedHat 7. After that it is possible to set root password.Stroboscope
A
6

In my case, I was using Centos 5.5. I found that the problem was because the mysql service was stopped some how. So I started mysql service with the command:

 /etc/init.d/mysqld start

So.. silly mistake.

Aracelyaraceous answered 18/1, 2013 at 9:38 Comment(0)
G
5

There are many solutions to this problem but for my situation, I just needed to correct the DATE on the machine/server (Ubuntu 16.04 Server).

i) Check the date of your server and correct it.

ii) Run sudo /etc/init.d/mysql restart

That should get it started.

Gonadotropin answered 29/9, 2016 at 10:34 Comment(0)
B
5

You might want to chek if the hard disk is full (df on the console), that's what ultimately triggered this error for me.

Brezhnev answered 6/8, 2020 at 0:10 Comment(0)
H
4

I was getting the error because I was running MAMP and my .sock file was in a different location. I just added a symbolic link where the app thought it should be that pointed to where it actually was and it worked like a charm.

Hyacinthe answered 7/7, 2012 at 5:55 Comment(1)
how can add symbolic link where the app thought it should be that pointed to where it actually was ?Generator
P
4

I also found that this was a permissions problem. I compared the MySQL files to a working install (both on Debian 6 squeeze) and had to make the following ownership changes (where mydatabase is any database(s) you have).

Ownership mysql:mysql:

chown mysql:mysql /var/lib/mysql
chown mysql:mysql /var/lib/mysql/ib*
chown mysql:mysql /var/lib/mysql/mydatabase
chown mysql:mysql /var/lib/mysql/mydatabase/*
chown mysql:mysql /var/lib/mysql/mysql/* 

Ownership mysql:root:

chown mysql:root /var/lib/mysql/mysql
chown mysql:root /var/run/mysqld 

Ownership mysql:adm:

chown mysql:adm /var/log/mysql
chown mysql:adm /var/log/mysql.err
chown mysql:adm /var/log/mysql.log* 
Pastis answered 23/6, 2013 at 13:50 Comment(0)
C
4

If you are using AWS (Amazon Web Services) Micro version, then it is a memory issue. When I ran

mysql

from the terminal it would say

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

So I tried the following and it would just fail.

service mysqld restart

After much searching, I found out that you have to create a swap file for MySQL to have enough memory. Instructions are listed: http://www.prowebdev.us/2012/05/amazon-ec2-linux-micro-swap-space.html.

Then, I was able to restart mysqld.

Chaschase answered 5/9, 2013 at 12:19 Comment(1)
I had the same problem on the AWS server "micro" instance and I can confirm that making the swap file DID fix the "ERROR 2002 (HY000): Can't connect to local MySQL server through socket /var/run/mysqld/mysqld.sock' (111)" problem. Thank you @Chaschase !Giga
A
4

For me - this was simply a case of MySQL taking a long time to load. I have over 100,000 tables in one of my databases and it did eventually start but obviously has to take a long time in this instance.

Alphonsoalphonsus answered 23/5, 2017 at 21:10 Comment(0)
S
3

you can always start mysql server by specifying the location of the mysql.sock file using the --socket option like

mysql --socket=/var/mysql/mysql.sock 

This will work even if the location of socket file in specified in a different location in the my.cnf file.

Southsouthwest answered 25/6, 2012 at 10:16 Comment(0)
G
3

For those whose any solution did not work, try:

cd /etc/mysql

check if my.cnf is present

nano my.cnf

and make sure you have only one bind-address as follows:

bind-address = 127.0.0.1

If not, that might be the problem, just exit nano and save the file.

and service mysql start

note that if you don't have nano (its a text editor) just install it with apt-get install nano and once in just press Ctrl+X to exit, dont forget to say Y to save and use the same file)

Gatehouse answered 24/10, 2014 at 7:21 Comment(1)
Unfortunately this did not work. This basically just says that only the local machine can access mysql. No remote connections.Roper
F
3
sudo service mysqld start

Worked for me, I'm using Centos

Faraway answered 15/2, 2016 at 5:46 Comment(0)
P
3

I had this problem too when trying to start the server, so many of the answers here that just say to start the server didn't work. The first thing you can do is execute the following to see if there are any config errors:

/usr/sbin/mysqld --verbose --help 1>/dev/null

I did have one error that showed up:

160816 19:24:33 [Note] /usr/sbin/mysqld (mysqld 5.5.50-0ubuntu0.14.04.1-log) starting as process 9461 ...
160816 19:24:33 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
160816 19:24:33 [Note] Plugin 'FEDERATED' is disabled.
160816 19:24:33 [ERROR] /usr/sbin/mysqld: unknown variable 'innodb-online-alter-log-max-size=4294967296'
160816 19:24:33 [ERROR] Aborting

A simple grep -HR "innodb-online-alter-log-max-size" /etc/mysql/ showed me exactly what file contained the offending line, so I removed that line from the file.

Then, checking my /var/log/mysql/error.log file I had:

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 671088640 bytes!
160816 22:46:46 [ERROR] Plugin 'InnoDB' init function returned error.
160816 22:46:46 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
160816 22:46:46 [ERROR] Unknown/unsupported storage engine: InnoDB
160816 22:46:46 [ERROR] Aborting

Based on this question the accepted solution wouldn't work because I couldn't even get the server started, so I followed what some of the comments said and deleted my /var/lib/mysql/ib_logfile0 and /var/lib/mysql/ib_logfile1 files.

This allowed the server to start and I was able to connect and execute queries, however checking my error log file it was quickly getting filled up with several tens of thousands of lines like this:

160816 22:52:15  InnoDB: Error: page 1415 log sequence number 82039318708
InnoDB: is in the future! Current system log sequence number 81640793100.
InnoDB: Your database may be corrupt or you may have copied the InnoDB
InnoDB: tablespace but not the InnoDB log files. See
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: for more information.

Based on a suggestion from here, to fix this I did a mysqldump and restore of all databases (see the link for several other solutions).

$ mysqldump -u root -p --allow-keywords --add-drop-database --comments --hex-blob --opt --quote-names --databases db_1 db_2 db_3 db_etc > backup-all-databases.sql
$ mysql -u root -p < backup-all-databases.sql

Everything appears to be working as expected now.

Prowel answered 17/8, 2016 at 6:39 Comment(1)
Checking /var/log/mysql/error.log helped in my case. There was [ERROR] Can't init tc log which was quickly fixed using following answer: dba.stackexchange.com/a/185006/163583Wrap
H
3

When you use localhost to connect to MySQL, the operating system uses the socket connector. However, if you use the 127.0.0.1 IP address, the operating system will use the TCP/IP connector. So, a possible solution when you’re having issues with the socket connector is trying to establish the connection using TCP/IP by specifying the 127.0.0.1 IP address instead of localhost.

Hebetic answered 6/2, 2022 at 6:26 Comment(0)
D
2

Adding

--protocol=tcp 

to the list of pramaters in your connection worked for me.

Dryad answered 7/11, 2012 at 14:47 Comment(0)
V
2

This was good enough for me

sudo /etc/init.d/mysql restart
Villosity answered 6/8, 2013 at 11:39 Comment(0)
E
2

I ran into this issue today. None of these answers provided the fix. I needed to do the following commands (found here https://mcmap.net/q/81389/-how-to-enable-innodb-in-mysql) for my mysql service to start:

sudo /etc/init.d/mysql stop
cd /var/lib/mysql/
ls ib_logfile*
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak
... etc ...
/etc/init.d/mysql restart

This was partly indicated by the following errors in /var/log/mysql/error.log:

140319 11:58:21 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
140319 11:58:21 [ERROR] Plugin 'InnoDB' init function returned error.
140319 11:58:21 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140319 11:58:21 [ERROR] Unknown/unsupported storage engine: InnoDB
140319 11:58:21 [ERROR] Aborting

I also saw the disk full error, but only when running commands without sudo. If the permissions check fails, it reports disk full (even when your partition is not even close to full).

Eno answered 19/3, 2014 at 18:5 Comment(0)
A
2

CentOS 7, 64 bit. Fresh installation.
In my case, the error was because I didn't have the right MySQL server and MySQL client installed.
Using yum, I removed mariadb and mysql-community edition. I downloaded the rpm's for the client and server from the official MySQL website and installed the server and client.

On installing the server, I was shown a message that the password to the root account for MySQL was stored in a file which I could view with sudo cat /root/.mysql_secret.

So after installing the client and server, I checked if MySQL was working (I think I rebooted before doing so) with the command sudo service mysql status and I got the result.

MySQL running (2601) [ OK ]

I logged into MySQL using the password from the .mysql_secret file:
mysql -uroot -pdxM01Xfg3DXEPabpf. Note that dxM01Xfg3DXEPabpf is the password mentioned in the .mysql_secret file.

and then typed entered the following command at the mysql prompt to change the password of root:

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('somePassword');

Everything worked fine from then on.

Animalize answered 13/8, 2014 at 6:46 Comment(1)
same case on RHEL6U6 with Server version: 5.6.23-enterprise-commercial-advanced.Crispa
R
2

This doesn't directly answer your question but a subset of it, namely using PythonAnywhere. I kept stumbling upon this question when looking for a fix so I'm adding it here in the hope that it will help others in my situation.


PythonAnywhere decided to change the database connection hostnames in order to improve efficiency and reliability, as detailed here:

The official host name you should use for connecting to your account's MySQL database instance has changed from mysql.server to yourusername.mysql.pythonanywhere-services.com. This bypasses a part of our infrastructure that has started showing problems in recent weeks, and it should be much more efficient and reliable than the old way.

Hence, you will need to update your hostname to the value highlighted above.

Reinaldo answered 4/5, 2016 at 19:37 Comment(0)
R
2

I've just had this problem. after a day of checking finally I've got the answer with that The mysql.sock file is created when MariaDB starts and is removed when MariaDB is shutdown. It won't exist if MariaDB is not running. maybe you didn't install MariaDB. YOU COULD FOLLOW THE INSTRUCTION BELOW: https://www.linode.com/docs/databases/mariadb/how-to-install-mariadb-on-centos-7 BEST

Roundtree answered 26/3, 2017 at 21:7 Comment(0)
B
2

If anyone looking for Intialization error

Can't connect to database "/var/run/mysql/mysql.sock"

When running civicrm & drupal just make below changes in

settings.php and civicrm.settings.php

only in places where you try to establish db connection

localhost to 127.0.0.1 #local installation

Besprinkle answered 10/7, 2017 at 11:6 Comment(0)
P
1

I had this socket error and it basically came down to the fact that MySQL was not running. If you run a fresh install, make sure that you install 1) the system package and 2) the panel installer (mysql.prefPane). The panel installer will allow you to goto your System Preferences and open MySQL, and then get an instance running.

Note that, on a fresh install, I needed to reset my computer for the changes to properly take effect. Following a reboot, I got a new instance running and was able to open up a connection to localhost with no problem.

Also of note, I apparently had previous versions of MySQL installed but had removed the panel, which makes it easy to get an instance of MySQL running for mac users.

A good link for this process of reinstalling: http://www.coolestguyplanettech.com/how-to-install-php-mysql-apache-on-os-x-10-6/

Playtime answered 3/7, 2012 at 4:8 Comment(0)
D
1

I used 127.0.0.1 for -h instead localhost and everything was OK. In other case had what had - error that above.

Dorsoventral answered 9/7, 2015 at 21:41 Comment(0)
W
1

After two days with this stuff, here's my two cents on this,

are you using hhvm?

if so, append the next line in /etc/hhvm/server.ini

hhvm.mysql.socket = /var/run/mysqld/mysqld.sock
Whomever answered 22/6, 2019 at 13:43 Comment(0)
E
1

I solved by deleting tc.log into /var/lib/mysql directory because it was corrupdet after full disk. Than, when i started mysql, the log file was created as new.

Eulogium answered 17/2, 2020 at 15:15 Comment(0)
P
0

I've deleted mysql.sock file and it worked. Putting the rights on it didn't work at all. Neither restarting, or whatever ...

Partan answered 9/3, 2015 at 9:1 Comment(0)
B
0

Try running following command:

sudo /etc/init.d/mysql start
Bakken answered 17/11, 2015 at 16:53 Comment(0)
H
0

Edit your config file /etc/mysql/my.cnf:

[client]
host        = 127.0.0.1
port        = 3306
socket      =/var/run/mysql/mysql.sock
Hawsepipe answered 3/4, 2016 at 19:58 Comment(0)
A
0

I had the same issue on Freebsd, I solved it by deleting the my.cnf file. Mysql version was 5.6.

It seems that after upgrading from 5.5 the old my.cnf remains and some incompatible parameters forces to an error. The old my.cnf had a lot of parameters but the new one only one

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

But if you do so, keep in mind that could be a security risk, because this without any further entry may open your db to the rest of the world ;-) If you won't that add at least this line

bind-address = 127.0.1.1
Ay answered 28/4, 2018 at 18:30 Comment(0)
O
0

There are a lot of potential problems that will lead to this error. The best thing, as suggested in another answer, is to check the log file. This can be found in different locations, depending on the platform. For me, this was located at /var/log/mysqld.err and the error was "No space left on device". After doing some cleanup, I could start the service and the problem was fixed.

Odontograph answered 22/9, 2020 at 7:38 Comment(0)
P
0

In case if you are reinstalling mariadb you must check of old process of mysql is still running find the process and kill

ps ax | grep mysql

sudo kill -9 mysql

Since InnoDB restarts itself you can use kill -15 in case of fresh installation* remove directory

sudo rm -rf /var/lib/mysql

create a default database structure and guide mariadb to read your data directory

sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Then reconfigure

sudo mysql_secure_installation
Pauper answered 5/7, 2022 at 16:14 Comment(0)
R
0

If you have tried everything and nothing works, you are at the right place. Just run:

brew doctor

Fix all issues it found, and then run:

brew remove mysql
brew install mysql
mysql.server start
Ranique answered 7/6, 2023 at 12:50 Comment(0)
F
0

I am using MacOS on Apple Silicon chip due to which I have two brew installed. The one that is chip compatible is installed as brew86

I faced this same problem and I was not able to start local mysql instance using brew86 services start mysql

What solved my problem was I ran brew86 doctor and I found that there was permission issues. I had to run some chown command as shown in the results of brew86 doctor

Hope this helps.

Francklyn answered 14/8, 2023 at 4:49 Comment(0)
F
-2

In my case the solution was that I had mariadb installed, which was aliased to mysql. So all service commands relating to mysql were not recognised... I just needed:

service mariadb start

And for good measure:

chkconfig mariadb on
Frogman answered 13/7, 2018 at 15:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.