how to open mysqld.log file - mysql

I am unable to start mysql on centos vmware.
I am trying to see the log file but I cant figure out how to open the file and see any error messages in it. Can someone show how to open the log file
the file does exist and returned this when I ran
ls -l mysqld.log
-rw-r-----. 1 mysql mysql 1279 Apr 21 08:12 mysqld.log
however, when I do this
gedit mysqld.log
I get this error message in gedit window.
"Could not open the file /var/log.mysqld.log"
"you dont have the permissions n ecessary to open the file."
so how to view contents of this file
here are the contents of my.cnf file if it helps
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Have you tried "sudo" command?
(if you have the super user permission.)
I mean:
$ sodu gedit mysqld.log
and then input your password.

Related

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

Mysql server won't work when using another data directory

I have an amazon ec2 instance running on Amazon Linux AMI. I'm trying to move the data directory for mysql on a second volume (mounted on /home/ec2-user/data) with following config file (/etc/my.cnf) but mysql fails to start:
[mysqld]
datadir=/home/ec2-user/data/mysql
socket=/home/ec2-user/data/mysql/mysql.sock
log-bin=/var/log/mysql/mariadb-bin
log-bin-index=/var/log/mysql/mariadb-bin.index
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
port=3306
socket=/home/ec2-user/data/mysql/mysql.sock
I get these error messages in the log file:
2017-10-12 14:06:33 20082 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2017-10-12 14:06:33 20082 [ERROR] Can't start server : Bind on unix socket: Permission denied
2017-10-12 14:06:33 20082 [ERROR] Do you already have another mysqld server running on socket: /home/ec2-user/data/mysql/mysql.sock ?
2017-10-12 14:06:33 20082 [ERROR] Aborting
When I set the config file back to former settings (to the backup of the data folder) everything works fine:
[mysqld]
datadir=/var/lib/mysql.bak
socket=/var/lib/mysql.bak/mysql.sock
log-bin=/var/log/mysql/mariadb-bin
log-bin-index=/var/log/mysql/mariadb-bin.index
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
port=3306
socket=/var/lib/mysql.bak/mysql.sock
What could be the cause of this problem? I've already checked for the permissions on the new data folder but that doesn't change anything.
Run this command:
chgrp -R mysql /home/ec2-user/data/mysql
chown -R mysql /home/ec2-user/data/mysql
Can you try the following config file ?
[mysqld]
datadir=/home/ec2-user/data/mysql
socket=/var/lib/mysql.bak/mysql.sock
log-bin=/var/log/mysql/mariadb-bin
log-bin-index=/var/log/mysql/mariadb-bin.index
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
port=3306
socket=/var/lib/mysql.bak/mysql.sock

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

What does mysqld_safe do in my.cnf?

Below is my MySQL config file. I am trying to understand how it works. What is the point of [mysqld_safe]? Hasn't [mysqld] already start MySQL? Why is the log-error and pid-file settings after it?
[mysqld]
# Settings user and group are ignored when systemd is used (fedora >= 15).
# If you need to run mysqld under different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
user=mysql
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Semisynchronous Replication
# http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
# uncomment next line on MASTER
;plugin-load=rpl_semi_sync_master=semisync_master.so
# uncomment next line on SLAVE
;plugin-load=rpl_semi_sync_slave=semisync_slave.so
# Others options for Semisynchronous Replication
;rpl_semi_sync_master_enabled=1
;rpl_semi_sync_master_timeout=10
;rpl_semi_sync_slave_enabled=1
# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html
;performance_schema
innodb_strict_mode=on
sql_mode=TRADITIONAL
;sql_mode=STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE
character-set-server=utf8
collation-server=utf8_general_ci
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
You can start MySQL server using either mysqld or mysqld_safe. mysqld_safe may itself try to execute mysqld but also may not. See the documentation (the first result in Google for mysqld_safe, btw):
mysqld_safe is the recommended way to start a mysqld server on Unix and NetWare. mysqld_safe adds some safety features such as restarting the server when an error occurs and logging runtime information to an error log file. NetWare-specific behaviors are listed later in this section.
Section [mysqld_safe] in the configuration file is for settings applied when you use mysqld_safe to start MySQL server instead of mysqld.

my.cnf changing datadir, 2days and still no luck

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.