I was trying to setup owncloud on WSL ubuntu but i am stuck on setting up mysql user and database since it popped up this :
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
but I have already installed mysql-server but it still doesn't work
It happen sometimes when you install mysql-server after php. You must locate your php.ini file and edit it with the good mysqld.sock path.
To locate the socket, be sure that your mysql-server is running, then type sudo locate mysqld.sock in your terminal.
Then, you have to edit your php.ini file and find the mysql.default_socket to assign it the path of the socket. Restart apache and/or php-fpm if you use it and voilĂ !
I haven't found anything online that's helped me address this error. I had to uninstall mysql, and I used this guide to uninstall. Then I reinstalled it. I got this error:
mysqld: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1.
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
So I uninstalled again, and attempted to uninstall the my.cnf file as well. After reinstalling a second time, I opened my.cnf and my.cnf.default files and [mysqld] is at the very top, with nothing (no comments or space) above it. I also checked to make sure that the files are in UTF-8. I still get this error when running brew postinstall mysql.
Here's what my.cnf file looks like, I moved the comments to the bottom to see if it would fix it:
[mysqld]
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1
# Default Homebrew MySQL server config
# Only allow connections from localhost
If anyone has any insight that would be greatly appreciated. I'm running MacOS Big Sur.
I installed mysql 5.6 on Ubuntu Server 16.04 using this method: https://askubuntu.com/questions/762384/install-mysql-5-6-on-ubuntu-16-04
But i'm having trouble getting mysqld to read /etc/mysql/my.cnf
Specifically i'm trying to set it up for an Atlassian Confluence installation where I have to add in these settings:
[mysqld]
character-set-server=utf8
collation-server=utf8_bin
default-storage-engine=INNODB
max_allowed_packet=256M
innodb_log_file_size=2G
I've checked mysqld --help --verbose and it has the my.cnf in its path. Here's the relevant output:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf The following
groups are read: mysqld server mysqld-5.6
I know that mysql is reading the file because if I change [mysqld] to [mysql] the arguments are correctly printed when I run mysql --print-defaults also if I put a wrong line in the file mysql will fail to start and tell me where the syntax error is. However mysqld does not report any arguments for mysqld --print-defaults or tell me about syntax errors in the file.
What else can I try?
Solved:
my.cnf was a symbolic link. I deleted it and made it an actual file. Now mysqld --show-defaults is working! So apparently mysql will follow the symlink but mysqld will not. Good to know.
my.cnf was a symbolic link. I deleted it and made it an actual file. Now mysqld --show-defaults is working. So apparently mysql will follow the symlink but mysqld will not.
For mysqld as I know only hard links works. Or maybe you just had wrong permission, on original my.cnf file to which you put symbolic link.
I've tried every solution posted here after running brew install mysql, and still no luck. On trying to start MySQL I get this:
me$ mysql.server start
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/mysql/data/cpe-98-14-179.159.nyc.res.rr.com.pid).
Or this:
me$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)
etc/my.cnf looks like this:
me$ sudo nano etc/my.cnf
Password:
[mysqld]
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
[mysql.server]
user=mysql
basedir=/usr/local/mysql
[client]
socket=/var/lib/mysql/mysql.sock
Are my permissions wrong? Is it possible my directories are messed up? If I could wipe everything clean and install from the website I'd try that at this point. Any help is MUCH appreciated!
sudo chown -R user_name /usr/local/var/mysql/
Replace user_name with your user name.
I'm trying to access mysql and when I run the mysql command, I get the following.
[root#ip-10-229-65-166
tpdatabase-1.8.0.28356]# mysql
ERROR 2002 (HY000): Can't connect to
local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2)
Doing this returns nothing
[root#ip-10-229-65-166 mysqld]# find
-name mysql*
[root#ip-10-229-65-166 mysqld]#
/etc/init.d/mysql stop
-bash: /etc/init.d/mysql: No such file or directory
[root#ip-10-229-65-173
tpdatabase-1.8.0.28356]# mysql_config
|grep -- --socket
--socket [/var/lib/mysql/mysql.sock]
Maybe a permissions problem?
I do have mysql installed using yum install mysql
I'm running CentOS 5.4 on a Amazon EC2 Cloud Instance
You need to install the server package:
sudo yum install mysql-server
After installation, you have to start the service:
sudo service mysqld start
rm -rvf /var/lib/mysql/ib_logfile*
touch /var/lib/mysql/mysql.sock
touch /var/lib/mysql/mysql.pid
chown -R mysql:mysql /var/lib/mysql
systemctl restart mysql
try this and check the permission of both /var/lib/mysql/mysql.sock and /tmp
We faced a similar problem in my office setup with the same OS. The actual thing that was happening was low space on the server. It is quite strange, but i believe if the server gets full the files cannot be loaded or of some other resort. Please check to be sure the space on the server is enough else you have to try removing the installed mysql and reinstall. Best of luck.
just search for mysqld, this is the server daemon:
find / | grep mysqld
If you found it, the server package may be correctly installed but without initd scripts. For testing, you may start the mysql server by hand executing the above file.
mysql might have been packaged separately as client and server. Check your package repositories to make sure that the server has been installed. The mysql package might only be the client. Check if there's a package called mysql-server or something similar. Check the list of files installed by the mysql package to see if it actually installs the server.
If the files are not even there, it's not a permissions problem. Also, you're running as root.
I recently encountered this problem after an upgrade on Ubuntu 18.04. The solution here solved it https://serverfault.com/a/957723/439448.
Make sure you have privileges to access the /var/lib/mysql/mysql.sock file. And if you still get the error, create a default my.cnf file with
[client]
socket = /path/to/mysql/data/mysql.sock
[mysqld]
server-id = 2
socket = /path/to/mysql/data/mysql.sock
port = 4000 #any port you wish
basedir = /path/to/mysql
datadir = /path/to/mysql/data
and initialize the database again. Make sure you give --defaults-file=/path/to/mysql/my.cnf when you initialize. If you get error saying files exist in /path/to/mysql/data, remove them and try again. Once done, when you run mysql also, give --defaults-file=/path/to/mysql/my.cnf.
Should work.
Before hitting mysql on command prompt make sure your correct my.cnf configuration file is in placed and set the permission of etc folder as
chmod -R 777
etc folder as below list to avoid
error MySQL - ERROR 2002 (HY000):
e.g /etc/my.cnf, /etc/mysql/my.cnf, $MYSQL_HOME/my.cnf [datadir]/my.cnf ~/.my.cnf