how to enable mysql bin log - mysql

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...

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

Where is my.ini in MacOS Sierra

I installed mysql with homebrew with this guide https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e
Now I need to delete the server variable NO_ZERO_DATE from the mysql configuration but i don't found mysql conf file. Where is located this file?
In MacOS the my.ini file is found as my.cnf, you can look for it in terminal with
> mysql --help
"Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf"
But if you hadn't found the cnf in the locations that help show you, try with the next command
> ls $(brew --prefix mysql)/support-files/my-*
For example, I got this file
/usr/local/opt/mysql/support-files/my-default.cnf
then you need to copy this file to one of your default directories, in my case /etc/my.cnf
> sudo cp /usr/local/opt/mysql/support-files/my-default.cnf /etc/my.cnf
Finally open your cnf file and delete STRICT_TRANS_TABLES from sql_mode
> nano /etc/my.cnf
sql_mode=NO_ENGINE_SUBSTITUTION
Exit with ctrl+x and press S
Don't forget to restart your mysql server
> sudo mysql.server stop
> sudo mysql.server start

my.cnf has no effect in MAMP 3

I'm trying to set the max_allowed_packet variable in MySQL (MAMP 3.0.6). I have created my.cnf in /Applications/MAMP/conf with the following content:
[mysqld]
max_allowed_packet = 256M
I have restarted MAMP but the changes refuse to pick up. PHPMyAdmin still shows 4,194,304 for "max allowed packet" in the "Variables" section.
What am I missing?
The path to my.cnf should be /Applications/MAMP/Library/my.cnf.
For MAMP 3.4 the correct place for my.cnf appears to be /etc/my.cnf, /etc/mysql/my.cnf, /Applications/MAMP/conf/my.cnf or ~/.my.cnf.
According to mysqld --verbose --help
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

Does MySQL included with MAMP not include a config file?

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