How to change mysql.sock? - mysql

I have installed mysql through binary installation and followed below steps
http://dev.mysql.com/doc/refman/5.0/en/binary-installation.html
Right now sock files are craeted on /tmp/mysql.sock when mysql service is started.
I want to know which configuration files need to be edited to change the path of mysql.sock
I tried the following steps to change mysql.sock path from /tmp/mysql.sock to /var/lib/mysql/mysql.sock
1.I tried to enter socketpath in /etc/my.cnf
socket =/var/lib/mysql/mysql.sock
2./etc/init.d/mysql
basedir=/var/lib/mysql
datadir=/var/lib/mysql/data
socket=/var/lib/mysql/mysql.sock
Can anybody help me to fix this issue.

Setting these variables in my.cnf should work just fine (Tested locally, Ubuntu 10.10).
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
Just make sure you're restarting MySQL Service?
Below is what I did, this is on Fedora (Since you're using RHEL this should more mimic your setup):
[root#rudi /]# ls /var/lib/mysql/
ibdata1 ib_logfile0 ib_logfile1 mysql mysql.sock
[root#rudi /]# ls /var/run/mysqld/
mysqld.pid
[root#rudi /]# nano /etc/my.cnf
[root#rudi /]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root#rudi /]# ls /var/lib/mysql/
ibdata1 ib_logfile0 ib_logfile1 mysql
[root#rudi /]# ls /var/run/mysqld/
mysqld.pid mysql.sock
The only thing that I changed was socket= this time, and restarting still worked fine.
Are you sure that you're not editing socket within the [client] section of my.cnf? It must be under the [mysqld] section.

Related

centos 7 Mysql 5.6.3 change data directory error

I try to change Mysql 5.6 data directory in centos 7 from default dir /var/lib/mysql to target dir /data1/mysqldata/mysql.
Follow is my operation step by step
1.Stop mysql service
2.Create target directory and chown
mkdir /data1/mysqldata
chown -R mysql:mysql /data1/mysqldata
2.Change /etc/my.cfg to below code
[mysqld]
datadir=/data1/mysqldata/mysql
socket=/data1/mysqldata/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
port=3306
socket=/data1/mysqldata/mysql/mysql.sock
4.Move data from default directory to target
mv /var/lib/mysql /data1/mysqldata/
5.Start mysql service
But I get error from /var/log/mysqld.log like this
190813 10:40:23 mysqld_safe Logging to '/var/log/mysqld.log'.
190813 10:40:23 mysqld_safe Directory '/data1/mysqldata/mysql' for UNIX socket file don't exists.
It's strange that Mysql run normaly in the default directory /var/lib/mysql when I undo all my config
My machine version is CentOS Linux release 7.6.1810 (Core), and Mysql Version is mysql Ver 14.14 Distrib 5.6.45, for Linux (x86_64)

Change MySQL /tmp to /somedrive/mysqltmp in centos 7 for error code 28

I am trying to change the temp location for MySQL from default /tmp to /somedrive/mysqltmp as i am getting
Errcode: 28 - No space left on device
Solution: 1
I tried to add a line in /etc/my.cnf as tmpdir=/somedrive/mysqltmp
then issued sudo service mysql stop and sudo service mysql start
After restart, i still see ERROR remains.
Solution: 2
Based on this I tried
mysqld --verbose --help | grep tmp
tmp-table-size 16777216
tmpdir /tmp
and then i tried
mysqld --tmpdir=/somedrive/mysqltmp
to change the defaults. But i am not able to change the tmp directory. I am not sure what i am missing!
I figured this out: Do changes under
[mysqld] as
tmpdir=/somedrive/mysqltmp
and then issue sudo service mysql stop and sudo service mysql start
Now check:
mysqld --verbose --help | grep tmp
tmp-table-size 16777216
tmpdir /somedrive/mysqltmp
This has happened to me before because mysql was using a my.cnf in a different location. Search for another my.cnf. You could also try moving the my.cnf file that you know of and see if mysql complains.
Do changes under
[mysqld] as
tmpdir=/somedrive/mysqltmp
and then issue sudo service mysql stop and sudo service mysql start
Now check:
mysqld --verbose --help | grep tmp
tmp-table-size 16777216
tmpdir /somedrive/mysqltmp

how to enable mysql bin log

OS: Mac OS X Hi Sierra(10.13.1)
MySQL: 5.7.20 (install by homebrew)
I want to enable bin log, so I should edit my.cnf file,
I typed below command to find my.cnf file
mysql --verbose --help | grep my.cnf
and result
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
/etc/my.cnf, /etc/mysql/my.cnf isn't exist in my mac.
So, I edit /usr/local/etc/my.cnf file.
[mysqld]
bind-address = 127.0.0.1
log-bin = ~/log
and I start mysql but it can't start.
mysql.server start
Starting MySQL
... ERROR! The server quit without updating PID file (/usr/local/var/mysql/*.pid).
When I remove bin-log in my.cnf, it can start!
How can I enable bin log??
Standby counsel
I missed server-id property in my.cnf...

Can't create/write to file (Errcode: 30)

I recently had an error on my mysql database and against better judgement (I'm not a server guy at all) I tried to resolve it through googling and changing server stuff...
So first off, mysql was showing this error "Can't create/write to file (Errcode: 30)"
I think I followed these answers which ended up causing more problems:
MySQL: Can't create/write to file '/tmp/#sql_3c6_0.MYI' (Errcode: 2) - What does it even mean?
http://nixcraft.com/showthread.php/14260-ERROR-1-(HY000)-Can-t-create-write-to-file-tmp-sql_9f3_0-MYI-(Errcode-13)
Only looking back, I see that these googled answers have different error codes, not "30"
Here is the log of the actions I did, causing the server to fail even more at the end (mysqld won't even restart up now)
[root#xxx ~]# /usr/sbin/lsof /tmp
[root#xxx ~]# /bin/umount -l /tmp
umount: /tmp: not mounted
[root#xxx ~]# /bin/umount -l /var/tmp
umount: /var/tmp: not mounted
[root#xxx ~]# cat /etc/my.cnf | grep tmpdir
[root#xxx ~]#
[root#xxx ~]# cat /etc/my.cnf | grep tmpdir
[root#xxx ~]# chown root:root /tmp
chown: changing ownership of `/tmp': Read-only file system
[root#xxx ~]# chmod 1777 /tmp
chmod: changing permissions of `/tmp': Read-only file system
[root#xxx ~]# /etc/init.d/mysqld restart
rm: cannot remove `/var/lock/subsys/mysqld': Read-only file system
rm: cannot remove `/var/lib/mysql/mysql.sock': Read-only file system
Stopping mysqld: [ OK ]
Starting mysqld: [FAILED]
[root#xxx ~]# chmod 777 /var/lock/subsys/mysqld
chmod: changing permissions of `/var/lock/subsys/mysqld': Read-only file system
[root#xxx ~]# chmod 777 /var/lib/mysql/mysql.sock
chmod: changing permissions of `/var/lib/mysql/mysql.sock': Read-only file system
[root#xxx ~]# /etc/init.d/mysqld restart
Stopping mysqld: [FAILED]
Starting mysqld: [FAILED]
[root#xxx ~]# /etc/init.d/mysqld restart
Stopping mysqld: [FAILED]
Starting mysqld: [FAILED]
[root#xxx ~]#
From the links listed above, you'll see that I tried following things such as
"check mysql config : my.cnf
cat /etc/my.cnf | grep tmpdir
I can't see anything in my my.cnf
add tmpdir=/tmp to my.cnf under [mysqld]
restart web/app and mysql server
/etc/init.d/mysqld restart"
" chown root:root /tmp
chmod 1777 /tmp
/etc/init.d/mysqld restart"
But yeah, I haven't touched it since because I think I would just be messing it up even more.
Server running is CentOS 6.5 64bit LAMP
Let me know if anyone could shed some insight or if I should provide anymore information. Thanks! Much appreciated.

Centos 6 64bit enable my.cnf

Can someone please tell me how to enable my.cnf options in CentOS 6?
I have all the expected .cnf files in /usr/share/mysql but they simply don't work.
/etc/init.d/mysqld --help --verbose
Usage: /etc/init.d/mysqld {start|stop|status|restart|condrestart|try-restart|reload|force-reload}
Default location is /etc/my.cnf as far as I'm aware of. Maybe you should try and copy them over there and restart?
my.cnf should be placed in /etc/ like /etc/my.cnf
The solution was to place the my.cnf file in /etc/mysql/my.cnf
the init.d script mysqld relais on the script in /usr/bin/my_print_defaults ..
this scripts takes as first input the "domain", e.g. mysqld_safe oder mysqld and outputs the config ..
this script merges the .cnf files from /etc/mysq/my.cnf + /etc/my.cnf + ~/.my.cnf together and outputs key=value pairs in the form of ..
]# /usr/bin/my_print_defaults mysqld
--datadir=/var/lib/mysql
--socket=/var/lib/mysql/mysql.sock
--user=mysql
--symbolic-links=0
so placing the .cnf files in /usr/share/mysql might be wrong ..