#Unable to run mysql locally (for localhost)

19 messages · Page 1 of 1 (latest)

fair stump
#

I am trying to set up a LAMP stack to develop a website for a class. I have an PHP website hosted using Apache on localhost. When I try to run mysql, I get this error:

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

How would I fix this error so that I can create a local database?
inxi in case you need it:

CPU: 8-core AMD Ryzen 7 PRO 4750U with Radeon Graphics (-MT MCP-)
speed/min/max: 1435/1400/1700 MHz Kernel: 6.4.11-arch2-1 x86_64 Up: 1d 20h 12m
Mem: 6.54/14.86 GiB (44.0%) Storage: 476.94 GiB (26.5% used) Procs: 374
Shell: Bash inxi: 3.3.29
copper lagoon
#

And also:- Arch Linux favors MariaDB, a community-developed fork of MySQL, aiming for drop-in compatibility.

#

.aw mariadb

gleaming basinBOT
fair stump
#
$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
$ systemctl status mysqld
○ mysqld.service - MySQL Server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: d>
     Active: inactive (dead)
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
#

I'd like to use mysql if I can since that's what we're using in my class. Eventually I have to use a web hosting service that also uses mySQL

#

would the commands/syntax look similar to mySQL if I used it locally?

copper lagoon
#

arch by default also alias mariadb to mysql.

#

.aw mariadb

gleaming basinBOT
copper lagoon
#

or if you want to stick to mysql. just run

#

sudo systemctl enable --now mysql.service

#

but it's not recommended

#

As MariaDB is the default implementation of MySQL in Arch Linux.

fair stump
#

sounds good. i'll try out mariadb. thank you for the help

copper lagoon
#

... solved