When I start zabbix server ,the log show below:
# tail 300f /tmp/zabbix_server.log
[Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock'
my mysql is working and mysql's acount(zabbix) is working;
[root#localhost data]# ps aux |grep mysql
root 49035 0.0 0.0 113264 1616 pts/2 S 17:00 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql
mysql 49170 0.0 5.5 1274804 215428 pts/2 Sl 17:00 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/var/lib/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root 49628 0.0 0.0 112660 972 pts/2 S+ 17:22 0:00 grep --color=auto mysql
[root#localhost data]# /usr/local/mysql/bin/mysql -u zabbix -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.20 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| zabbix |
+--------------------+
2 rows in set (0.00 sec)
mysql>
the sock is here:
[root#localhost data]# cd /var/lib/mysql/
[root#localhost mysql]# ll
total 188504
drwxr-xr-x 2 mysql mysql 4096 Jan 24 12:30 mysql
srwxrwxrwx 1 mysql mysql 0 Jan 24 17:00 mysql.sock
-rw------- 1 mysql mysql 6 Jan 24 17:00 mysql.sock.lock
drwxr-xr-x 2 mysql mysql 8192 Jan 24 12:30 performance_schema
drwxr-xr-x 2 mysql mysql 12288 Jan 24 15:12 zabbix
[root#localhost mysql]#
my zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBName=zabbix
DBUser=zabbix
DBPassword=123456
what something wrong,please help me.
thank you so much at first
It looks like your DB socket is /var/lib/mysql/mysql.sock.
So you need to configure zabbix_server.conf for that:
DBSocket=/var/lib/mysql/mysql.sock
Doc: https://www.zabbix.com/documentation/3.4/manual/appendix/config/zabbix_server
Install like this
useradd zabbix
yum install net-snmp-devel libxml2-devel libcurl-devel
./configure --prefix=/usr/local/zabbix-3.4.6/ --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make
make install
cp /home/zabbix/zabbix-3.4.6/misc/init.d/fedora/core/zabbix_server /etc/init.d/
mysql add account:
create database zabbix character set utf8;
grant all on zabbix.* to zabbix#localhost identified by '123456';
flush privileges;
use zabbix;
source /home/zabbix/zabbix-3.4.6/database/mysql/schema.sql
source /home/zabbix/zabbix-3.4.6/database/mysql/images.sql;
source /home/zabbix/zabbix-3.4.6/database/mysql/data.sql;
exit;
Just restart the server where Zabbix is running.
Related
I have installed some production, there is mysql embedded instance in production. Installation is successful, but when I tried to connect mysql instannce, I got following error messages.
[root#MiWiFi-R3D-srv bin]# ./mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/msql.sock' (2)
[root#MiWiFi-R3D-srv bin]#
[root#MiWiFi-R3D-srv bin]#
I can sure mysql instance is running.
aam 13390 1 0 08:01 ? 00:00:00 /bin/sh /opt/SIU_MANAGER/mysq /bin/mysqld_safe --defaults-file=/var/opt/SIU_MANAGER/mysql/my.cnf --pid-file=/var/opt/AAM/mysql/data/my.pid --ledir=/opt/AAM/mysql/bin --basedir=/opt/AAM/mysql --tmpdir=/var/opt/AAM/mysql/tmp/ --datadir=/var/opt/AAM/mysql/data --character-sets-dir=/opt/AAM/mysql/share/charsets/ --lc-messages-dir=/opt/AAM/mysql/share --lc-messages=en_US --user=bin
aam 13578 13390 0 08:01 ? 00:00:02 /opt/AAM/mysql/bin/mysqld --defaults-file=/var/opt/AAM/mysql/my.cnf --basedir=/opt/AAM/mysql --datadir=/var/opt/AAM/mysql/data --plugin-dir=/opt/AAM/mysql/lib/plugin --tmpdir=/var/opt/AAM/mysql/tmp/ --character-sets-dir=/opt/AAM/mysql/share/charsets/ --lc-messages-dir=/opt/AAM/mysql/share --lc-messages=en_US --log-error=MiWiFi-R3D-srv.err --pid-file=/var/opt/AAM/mysql/data/my.pid
root 17786 11762 0 08:27 pts/1 00:00:00 grep --color=auto mysql
I did little research. Mysql offical solution is that execute sql in mysql, but if I can not connect sql
I can not execute any sql.
Mysql offical solution https://dev.mysql.com/doc/mysql-security-excerpt/5.7/en/account-locking.html
When used with ALTER USER, these clauses specify the new locking state
for an existing account. In the absence of either clause, the account
locking state remains unchanged.
This is mysql version.
[root#MiWiFi-R3D-srv bin]# ./mysqladmin -V
./mysqladmin Ver 8.42 Distrib 5.7.25, for linux-glibc2.12 on x86_64
[root#MiWiFi-R3D-srv bin]#
How do I unlcok root user?
PS: I have root privillage of OS.
Thank you for answer me.
It looks like, for some reason, your communication socket for MySQL is being created in /tmp, and is presumably being deleted by some process that periodically cleans up /tmp.
You can get it back by restarting the mysqld process through whatever means is appropriate to your system.
You should also move it out of /tmp, perhaps into /var/run.
I am trying to turn off ONLY_FULL_GROUP_BY in my local ~.my.cnf options file.
Here are my system details:
$ sudo service mysql status
* /usr/bin/mysqladmin Ver 8.42 Distrib 5.7.25, for Linux on x86_64
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.7.25-0ubuntu0.18.04.2
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 19 min 35 sec
Threads: 1 Questions: 14 Slow queries: 0 Opens: 108 Flush tables: 1
Open tables: 27 Queries per second avg: 0.011`
~.my.cnf has the following content:
[mysqld]
key_buffer_size=32M
max_allowed_packet=512M
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,
ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
When I use "mysqld --help --verbose" this is what I see:
$ sudo mysqld --help --verbose
mysqld Ver 5.7.25-0ubuntu0.18.04.2 for Linux on x86_64 ((Ubuntu))
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Starts the MySQL database server.
Usage: mysqld [OPTIONS]
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
So my ~/.my.cnf is being read last meaning that it should override any settings made in previous files.
When I use "mysqld --print-defaults" to see what is being set, here's what I get:
$ sudo mysqld --print-defaults
mysqld would have been started with the following arguments:
--user=mysql --pid-file=/var/run/mysqld/mysqld.pid
-- socket=/var/run/mysqld/mysqld.sock --port=3306 --basedir=/usr
--datadir=/var/lib/mysql --tmpdir=/tmp --lc-messages-dir=/usr/share/mysql
--skip-external-locking
--bind-address=127.0.0.1 --key_buffer_size=16M --max_allowed_packet=16M
--thread_stack=192K --thread_cache_size=8
--myisam-recover-options=BACKUP --query_cache_limit=1M
--query_cache_size=16M --log_error=/var/log/mysql/error.log
--expire_logs_days=10 --max_binlog_size=100M --key_buffer_size=32M
--max_allowed_packet=512M
--sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,
ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
It would appear my settings have been actioned.
Using another method shows the same:
$ sudo mysqladmin variables | grep sql_mode
| sql_mode
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,
ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
$ sudo mysqladmin variables | grep max_allowed_packet
| max_allowed_packet| 16777216
However, when I look at the settings of sql_mode and max_allowed_packet in mysql itself I see they still have their system default values:
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.25-0ubuntu0.18.04.2 (Ubuntu)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select ##global.sql_mode;
+--------------------------------------------------------------------------+
| ##global.sql_mode |
+--------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE, |
| NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER, |
| NO_ENGINE_SUBSTITUTION |
+--------------------------------------------------------------------------+
mysql> select ##global.max_allowed_packet;
+-----------------------------+
| ##global.max_allowed_packet |
+-----------------------------+
| 16777216 |
+-----------------------------+
What am I'm doing wrong?
Your personal ~/.my.cnf can only affect programs run by you, for example mysql client or mysqldump, etc.
It does no good to write a section for [mysqld] in your personal ~/.my.cnf file, because your user is probably not the one who launches mysqld.
You could declare your preferred sql_mode for your own sessions in the MySQL client by writing the option into a [client] section:
[client]
max_allowed_packet=512M
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,
ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
But [client] only applies to MySQL tools like mysql and mysqldump. It doesn't affect any of your own apps, like if you code something in Java, Python, Ruby, or PHP, etc.
If you want an option to affect all clients, including your apps, you must apply the option in the global MySQL Server config, which is probably /etc/my.cnf as described in the other answer.
You can also change many global options dynamically without restarting mysqld. I often do this right after I edit the /etc/my.cnf file, so I can get the change without interrupting service.
mysql> SET GLOBAL sql_mode='...whatever...';
Final note: I recommend NOT disabling ONLY_FULL_GROUP_BY. That sql_mode is a useful way to prevent bogus query results. It's much better to keep that sql_mode enabled, and fix your SQL queries so they don't cause errors.
mysqld usually runs as its own user mysql, so ~/.my.cnf is meaningless unless it is in the home directory of the mysql user. For server configurations, you typically put settings in the /etc/my.cnf file or /etc/my.cnf.d depending on your mysql version.
When I start mysql using System Preferences>MySQL>StartMySQLServer, then I can do this:
/usr/local/mysql-5.7.10-osx10.9-x86_64/bin$ ./mysql -uroot -p
Enter password: <password shown me during installation>
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.10
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'my new password';
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql>
And I can see the mysql process created by System Preferences>MySQL>StartMySQLServer:
/Library/LaunchDaemons$ ps -e | grep mysql
1735 ?? 0:00.31 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid
1743 ttys000 0:00.00 grep mysql
/Library/LaunchDaemons$
But after stopping the server using System Preferences>MySQL, I am unable to start the mysql server using the command line (following the instructions in the docs):
/usr/local/mysql-5.7.10-osx10.9-x86_64/bin$ sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
/usr/local/mysql-5.7.10-osx10.9-x86_64/bin$ ./mysql -uroot -p
Enter password: <new password>
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
There's no mysql process:
/usr/local/mysql-5.7.10-osx10.9-x86_64/bin$ ps -e | grep mysql
1920 ttys001 0:00.00 grep mysql
/usr/local/mysql-5.7.10-osx10.9-x86_64/bin$
How are you supposed to start the mysql server from the command line?
You have to start the mysql server first before you can connect. I think you you must start mysqld daemon but i am not sure
I use following command on terminal to start mysql:
mysql.server start
Give it a try.
Actually, the answer you want is:
1.first, add your mysql path to ~/.bash_profile:
export PATH=${PATH}:/usr/local/mysql/bin
Save it and open a new terminal.
2.Then, you can start/stop/restart mysql by,(you can also choose to start it from the "mysql" in "system preferences" or to forget it):
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart
3.After you start, use command "mysql" at your will~
This error showed up.
Mysql2::Error
Unknown MySQL server host '/tmp/mysql.sock' (2)
I already have the mysql.sock on my /tmp/ folder
eldiablo:tmp sbpipb$ pwd
/tmp
eldiablo:tmp sbpipb$ ls -l
total 8
-rw------- 1 sbpipb wheel 0 Nov 14 17:51 aprm0fjKv
drwx------ 3 sbpipb wheel 102 Nov 14 17:21 com.apple.launchd.1O4gD8GW17
drwx------ 3 sbpipb wheel 102 Nov 14 17:21 com.apple.launchd.xksWCs46sn
lrwxr-xr-x 1 root wheel 39 Nov 14 17:50 mysql.sock -> /Applications/MAMP/tmp/mysql/mysql.sock
srwxr-xr-x 1 sbpipb wheel 0 Nov 14 17:22 steam_chrome_shmem
I don't have any problem accessing mysql through the commandline though, and the password set on the db config is correct.
eldiablo:tmp sbpipb$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.5.38 Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
I've fixed it by putting the socket parameter in the database.yml
socket: /Applications/MAMP/tmp/mysql/mysql.sock
This fixed it!
Today I updated openssl (due to the recent heartbleed vulnerability) and all of a sudden mysql is acting strangely. I was recently able to modify tables, but now when I try to add a column I get:
ERROR 1005 (HY000): Can't create table '#sql-34f_872b' (errno: 13)
And trying to do show tables results in:
ERROR 1018 (HY000): Can't read dir of './<db>/' (errno: 13)
During the openssl upgrade there was a prompt asking about an upgrade to mysql. It was asking if I want to keep my current /etc/my.cnf or if I wanted to replace with the new one - I selected to keep.
Typically this would be a permissions issue, and I've tried and tested the permissions on the mysql datadir (using this answer from a similar question).
A few other strange things:
When I try these commands, I'm using the mysql command client and logged in as root
I am able to insert new rows into existing tables
I feel like the openssl upgrade is too much of a coincidence to ignore, and I'm not keen on the idea of restarting mysqld without really knowing that the server will definitely come back up (since there's an unknown issue going on here).
Any ideas?
Reply to comments and questions:
Output of ls -ltrFa:
remy#ip-10-168-9-52:~$ ls -ltrFa /vol/mysql/
total 49367084
-rwxr-xr-x 1 mysql mysql 0 Feb 11 2013 debian-5.5.flag*
drwxr-xr-x 2 mysql mysql 4096 Feb 11 2013 test/
drwxr-xr-x 2 mysql mysql 4096 Feb 11 2013 performance_schema/
drwxr-xr-x 2 mysql mysql 4096 Feb 11 2013 mysql/
-rwxr-xr-x 1 mysql mysql 6 Feb 11 2013 mysql_upgrade_info*
-rwxr-xr-x 1 mysql mysql 25 Feb 12 2013 slave-relay-bin.index*
-rwxr-xr-x 1 mysql mysql 126 Feb 12 2013 slave-relay-bin.000001*
drwxr-xr-x 6 mysql mysql 4096 Oct 14 14:35 ./
drwxr-xr-x 2 mysql mysql 4096 Apr 3 15:50 jsbin/
drwxrwxrwx 5 root root 4096 Apr 9 16:07 ../
-rwxr-xr-x 1 mysql mysql 50417631232 Apr 9 17:24 ibdata1*
-rwxr-xr-x 1 mysql mysql 67108864 Apr 9 17:24 ib_logfile0*
-rwxr-xr-x 1 mysql mysql 67108864 Apr 9 17:25 ib_logfile1*
Output of ps aux | grep mysql:
mysql 847 1.4 83.9 16342212 14681964 ? Ssl 2013 3646:34 /usr/sbin/mysqld
remy 4038 0.0 0.0 101816 2824 pts/0 S+ 16:58 0:00 mysql -uroot -px xxxxx jsbin
Note that I've also tried running mysql using sudo -u mysql mysql -uroot -pxxx jsbin and it results in the same issue.
Here is the the log from the apt-get upgrade openssl which shows mysql being included in the update: https://gist.github.com/remy/10291829
Server is ubuntu-precise-12.04-amd64 (installations are all via apt-get rather than manually compiled).
Versions of mysql:
$ mysqld --version
mysqld Ver 5.5.29-0ubuntu0.12.04.1 for debian-linux-gnu on x86_64 ((Ubuntu))
$ mysql --version
mysql Ver 14.14 Distrib 5.5.35, for debian-linux-gnu (x86_64) using readline 6.2
The following worked for me :
rm /var/lib/mysql/ib_logfile*
/etc/init.d/mysql restart
So it turns out that apt-get upgrade openssl actually upgrades everything else in it's wake - along with openssl. So somehow MySQL got caught in that update.
By accident (an AWS backup actually) the machine was rebooted, and all problems went away.
I'm pretty sure this is because some of MySQL's libraries had been updated, but the server that was loaded in memory was somehow incompatible.
I wouldn't generally recommend a random restart to fix these issues, but in this particular situation, it did the job.
The most-likely reason I can think of for this is due to some upgrade process or script trying to alter table defaults and/or one of the dependent tools adding a table and immediately altering it. This could step on a documented limitation in MySQL that prevents you from adding and dropping foreign keys in the same ALTER statement.:
* http://bugs.mysql.com/bug.php?id=68286
Can you check your logs to see what was running when the failure happened and then manually edit the update script or manually make the change so it's skipped?
I think keeping your my.cnf was the right way to go too. But if you can't get enough info from the logs as noted above, you could try disabling FK checks in there, https://dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html
...that does risk some trash data though, so use as a last resort.
As for OpenSSL, this was triggered by the update but not specific to OpenSSL. Any update to 5.5.29 that ran a complex ALTER might have triggered this