The mysql_config program is reporting the socket file location as:
/var/lib/mysql/mysql.sock
But in /etc/my.cnf, the location is clearly stated as:
/tmp/mysql.sock
When I use "mysqladmin variables" to check the socket, it is reported correctly. Why is mysql_config incorrect, and how can I fix it?
mysql_config --socket shows "The default Unix socket file, defined when configuring MySQL" (i.e. at compile-time).
What OS are you using?
I use OSX and it very rarely uses default locations for, well, anything!
The '/tmp/mysql.sock' value is the default for my.cnf out of the box, as far as I am aware you should change your my.cnf to reflect your socket location in respect of your environment.
In MAMP (apache, mysql,php bundle for OSX) it is located in 'Applications/MAMPP/tmp/mysql/mysql.sock'
MAMP my.cnf [default]
# The MySQL server
[mysqld]
#port = 9999
socket = /Applications/MAMP/tmp/mysql/mysql.sock
Related
I am on macOS 10.12.3. Installed and running MySQL through Homebrew. Whenever i try to start MySQL with brew services start mysql or sudo mysql.server start command on terminal, it starts. Following is my my.cnf file residing into /etc/my.cnf
[mysqld]
user=mysql
basedir=/usr/local/Cellar/mysql/5.7.17
datadir=/usr/local/var/mysql
port=3306
server_id=1
socket=/tmp/mysql.sock
[client]
user=mysql
basedir=/usr/local/Cellar/mysql/5.7.17
datadir=/usr/local/var/mysql
port=3306
server_id=1
socket=/tmp/mysql.sock
Then i try to connect to MySQL using Perfect-MySQL following the instructions there. But failed to locate and connect to socket file. Got the following error,
[ERR] MySQL connection error: Can't connect to local MySQL server through socket '' (2)
[ERR] Error msg: error("MySQL server has gone away")
Clearly it failed to identify socket file path which should be /tmp/mysql.sock. But after running mysql server i found mysql.sock.lock.lock file into /tmp/ folder, there were no mysql.sock file.
Then i changed the my.cnf file with socket=/tmp/mysql.sock.lock.lock . but same result.
I have no other mysql client/service installed and tried freshly reinstalling with homebrew several times. Same result everytime.
I have tried with a lot of other options but no luck. CLearly i am missing something. Can someone please shade some light on it ?
How and from where i can set mysql.sock path ?
This is strange for me because when i run sudo find / -type s
the mysql.sock location is /opt/lampp/var/mysql/mysql.sock, the problem is when i start ruby using rail s an error came up
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
i know i could change database.yml file configuration by adding
socket: /opt/lampp/var/mysql/mysql.sock
fix everthing but i was wondering why ruby's socket is pointed to /var/run/mysqld/mysqld.sock when i have /opt/lampp/var/mysql/mysql.sock when i run sudo find / -type s. Can someone explain why rails act like this and help me change ruby on rails default socket configuration to /opt/lampp/var/mysql/mysql.sock
Additional Info
When i run ps -aef | grep mysql mysql socket still points to /opt/lampp/var/mysql/mysql.sock
I have tried to edit my.cnf under /etc/mysql since i dont have my.cnf in tmp/my.cnf and change socket to /opt/lampp/var/mysql/mysql.sock
You can create a soft of file /opt/lampp/var/mysql/mysql.sock to /var/run/mysqld/mysqld.sock by command:
ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock
OR
change the socket file path in my.cnf or my.ini file.
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
Hi i have been trying this for hours upon hours, this forum is my last resort
sfter googling hundreds of pages.
PROBLEM:
Sorry for the length but i am supplying in detail of what i have tried
I have set up mysql and its working fine, i now need to change the data-storage to point at my External HD.
With mac osx there is no default my.cnf so i copied
my-huge.cnf from /usr/local/mysql-5.1.53-osx10.6-x86/support-files, now if it makes any odds i also have a 'mysql' folder in local also.
when i place and rename my-huge.cnf into /etc
i renamed it to my.cnf like instructed,
it works as normal if i dont add a datadir field which looks like this
datadir= /Volumes/Elements/database,
i have also copied my old data to my new location using
sudo cp -R -p /var/lib/mysql /Volumes/Elements/database
Everything workds fine unless i add the field datadir = /Volumes/Elements/database
to the my.cnf file, if i do i get the error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
my.cnf file looks like the following
Macintosh-100:support-files seanf$ cd /etc
Macintosh-100:etc seanf$ sudo nano my.cnf
Password:
Macintosh-100:etc seanf$ nano my.cnf
Macintosh-100:etc seanf$ my.cnf > /Desktop/blah.txt
-bash: /Desktop/blah.txt: No such file or directory
Macintosh-100:etc seanf$ my.cnf < /Desktop/blah.txt
-bash: /Desktop/blah.txt: No such file or directory
Macintosh-100:etc seanf$ nano my.cnf
GNU nano 2.0.6 File: my.cnf
# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/mysql/data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]l
datadir = /Volumes/Elements/database
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer_size = 384M
etc....
I hope someone can shed light on this, i have an assignment due and have spent 2 days trying to get this working on my external
Also even when mysql is working and i type mysqld i get errors if this is an issue?
Macintosh-100:lib s$ mysqld
101201 13:31:13 [Warning] '--skip-locking' is deprecated and will be removed in a future >release. Please use '--skip-external-locking' instead.
101201 13:31:13 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86/data>/Macintosh-100.lower-test
101201 13:31:13 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86/data>/Macintosh-100.lower-test
mysqld: Can't change dir to '/usr/local/mysql-5.1.53-osx10.6-x86/data/' (Errcode: 13)
101201 13:31:13 [ERROR] Aborting
101201 13:31:13 [Note] mysqld: Shutdown complete
Macintosh-100:lib s$
Thanks for your time i hope an expert can answer this
Though I haven't played with datadir property but I've changed data storage location to the external HD by mounting default location to it as follows:
Backup your current data directory
Delete everything from your data directory
Mount it to your external HD (mount /var/lib/mysql/data /dev/XXX)
I've done it at Ubuntu Server. When changing InnoDB specific directories I've noticed that one have to be careful with rights (apparmord in case of ubuntu). When mysql cannot perform some filesystem operation I find its error messages very misleading. Sometimes it is really helpful to study it's error.log (/var/log/mysql/error.log in my case).
Hope this helps you to resolve your issue ASAP.
Use:
rsync -Pa /var/lib/mysql /Volumes/Elements/database
instead of:
cp -R -p /var/lib/mysql /Volumes/Elements/database
"rsync -a" can keep some permissions important for mysql.
I can't seem to find the my.cnf or other config file for the MySQL that comes with MAMP. Does it not include one?
The MySQL server of MAMP (not PRO) will be started without any my.cnf file. But you can create your own my.cnf file.
Stop servers
Create a my.cnf file in /Applications/MAMP/conf/
Add your content in to my.cnf
Save my.cnf
Start servers
You do not have to put a complete configuration in the my.cnf file. You can just add parts of a configuration ... for example:
[mysqld]
max_allowed_packet = 64M
Some standard my.cnf variants can be found at /Applications/MAMP/Library/support-files/
Invoking mysqld --verbose --help | less on the MAMP mysqld binary reports:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /Applications/MAMP/conf/my.cnf ~/.my.cnf
Copy one of the variants in /Applications/MAMP/Library/support-files/ to one of the locations in mysqld's search order above, and you should be good to go after restarting the daemon.
Since MAMP server generates my.cnf dynamically on MAMP server startup, it's best to use the following steps to add or edit the MySQL configuration:
Stop MAMP server
Goto Files > Edit Template > MySQL
Make the necessary changes and save
Restart MAMP
I tried this on MAMP PRO 3.5.
For MAMP 3.5 on Mac El Capitan, only this worked for me:
Stop servers
Create a my.cnf file in /Applications/MAMP/Library/
Add your content into my.cnf like
[mysqld]
max_allowed_packet = 64M
Save my.cnf
Start servers
Not required to change ownership of file, it should work. Verify by running SHOW VARIABLES in phpmyadmin and look for your changed setting.
No, it doesn't come with the my.cnf file
I found that MAMP PRO will create a my.cnf by default on startup under the MAMP/tmp directory if a ~/my.cnf is not provided ... grepping ps aux you may find the default location under /Applications/MAMP/tmp/my.cnf ...
ps aux | grep mysql
Which provided the following...
root 284 0.0 0.1 2435544 532 ?? Ss 12:00AM 0:00.06 /bin/sh /Applications/MAMP/Library/bin/mysqld_safe
--defaults-file=/Applications/MAMP/tmp/mysql/my.cnf
--port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock
--user=mysql --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid
--log-error=/Applications/MAMP/logs/mysql_error_log.err
--tmpdir=/Applications/MAMP/tmp/mysql/tmpdir
--datadir=/Library/Application Support/appsolute/MAMP PRO/db/mysql