新安装的MySQL5.7,登录时提示密码错误,安装的时候并没有更改密码,后来通过免密码登录的方式更改密码,输入update mysql.user set password=password('123456') where user='root'时提示ERROR 1054 (42S22): Unknown column 'password' in 'field list',原来是mysql数据库下已经没有password这个字段了,password字段改成了
authentication_string
上图是设置root密码之后的加上注释
进去mysql里设置root密码
mysql> update mysql.user set authentication_string=password('123456') where user='root' ;
Query OK, 1 row affected, 1 warning (0.09 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> exit
Bye
[root@mha ~]# vi /etc/my.cnf ###进去把skip-grant-tables注释了
[root@mha ~]# systemctl restart mysqld
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
1、修改用户密码:
mysql> alter user 'root'@'localhost' identified by 'youpassword'; 或者set password=password("xxxxx");
2、授权远程访问:
grant 权限 on . to '用户'@'%’ identified by '123456';
##############%是代表所有地址;第一个是库,第二个是表;
权限:
all privileges (所有权限)
insert,update,delete,select(增改删查)
3、查看用户的权限
select from mysql.user where user='root'\G;
4、添加中文字符集
在[mysqld]下添加
character_set_server=utf8
5、通过授权:
mysql> grant all privileges on zabbix. to 'zabbix'@'localhost' identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
有时候,只是为了自己测试,不想密码设mysql> 置得那么复杂,譬如说,我只想设置root的密码为123456。
必须修改两个全局参数:
首先,修改validate_password_policy参数的值
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
这样,判断密码的标准就基于密码的长度了。这个由validate_password_length参数来决定。
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 8 |
+----------------------------+
1 row in set (0.00 sec)
validate_password_length参数默认为8,它有最小值的限制,最小值为:
validate_password_number_count
- validate_password_special_char_count
- (2 * validate_password_mixed_case_count)
其中,validate_password_number_count指定了密码中数据的长度,validate_password_special_char_count指定了密码中特殊字符的长度,validate_password_mixed_case_count指定了密码中大小字母的长度。
这些参数,默认值均为1,所以validate_password_length最小值为4,如果你显性指定validate_password_length的值小于4,尽管不会报错,但validate_password_length的值将设为4。如下所示:
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 8 |
+----------------------------+
1 row in set (0.00 sec)
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 4 |
+----------------------------+
1 row in set (0.00 sec)
如果修改了validate_password_number_count,validate_password_special_char_count,validate_password_mixed_case_count中任何一个值,则validate_password_length将进行动态修改。
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 4 |
+----------------------------+
1 row in set (0.00 sec)
mysql> select @@validate_password_mixed_case_count;
+--------------------------------------+
| @@validate_password_mixed_case_count |
+--------------------------------------+
| 1 |
+--------------------------------------+
1 row in set (0.00 sec)
mysql> set global validate_password_mixed_case_count=2;
Query OK, 0 rows affected (0.00 sec)
mysql> select @@validate_password_mixed_case_count;
+--------------------------------------+
| @@validate_password_mixed_case_count |
+--------------------------------------+
| 2 |
+--------------------------------------+
1 row in set (0.00 sec)
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 6 |
+----------------------------+
1 row in set (0.00 sec)
https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
初始化mysql时候改的密码
5、允许Zabbix web console 对特定IP段可用 (可选)
编辑文件 /etc/httpd/conf.d/zabbix.conf,
vi /etc/httpd/conf.d/zabbix.conf
添加允许访问 zabbix web interface的ip段. 如果设置 ‘Allow from All’, 这可以允许全部可以访问
#
Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
<Directory"/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModulemod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value date.timezone Asia/Shanghai
</IfModule>
</Directory>
<Directory"/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory"/usr/share/zabbix/include">
Require all denied
</Directory>
启动zabbix-server 和zabbix-agent。重启httpd,,并设置zabbix-server和zabbix-agent开机自动启动
systemctl start zabbix-server
systemctl start zabbix-agent
systemctl restart httpd
systemctl restart mariadb
systemctl enable zabbix-server
systemctl enable zabbix-agent ---- (可选)
6、安装并部署zabbix
准备:
rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX
rpm -Uv http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
安装:
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway
部署:
(1)编辑 file /etc/httpd/conf.d/zabbix:
vi /etc/httpd/conf.d/zabbix.conf
更新时区:
php_value date.timezone Asia/Shanghai
重启httpd
systemctl restart httpd
(2)创建MySQL 数据库和用户
登录MariaDB:
mysql –u root –p
创建一个数据库‘zabbixdb’和数据库用户‘zabbix’
MariaDB [(none)]> create database zabbix character set utf8;
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by '123456';
MariaDB [(none)]> flush privileges;
(3)数据库导入zabbix template
使用数据库用户zabbix登录数据库
mysql –uzabbix –p
切换到zabbix数据库
use zabbix
导入模板数据
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql
(4)配置Zabbix server
编辑文件/etc/zabbix/zabbix_server.conf,
vi /etc/zabbix/zabbix_server.conf
配置下面的三个参数
[...]
DBName=zabbix
[...]
DBUser=zabbix
[...]
DBPassword=123456
[...]
(5)配置zabbix-agent
vi /etc/zabbix/zabbix_agentd.conf
配置zabbix server 的ip
[...]
Line 85 - Specify Zabbix server
Server=127.0.0.1
[...]
Line 126 - Specify Zabbix server
ServerActive=127.0.0.1
[...]
Line 137 - Specify Zabbix server Hostname or IP address
Hostname=127.0.0.1
[...]
(6)修改PHP 设置
修改php.ini为zabbix 建议的设置
编辑文件 php.ini,
vi /etc/php.ini
设置下面的参数.
max_execution_time = 600
max_input_time = 600
memory_limit = 256
Mpost_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Shanghai
(7)web页面安装zabbix
前期工作做好了,就都OK
web页面默认登陆密码和用户名,Admin/zabbix
zabbix监控mysql
zabbix客户端的mysql配置要把client配置好:
[client]
#socket=/app/mysql/lib/mysql.sock
socket=/var/lib/mysql/mysql.sock
user=root
host=localhost
password=123456
mysql的zabbix客户端正确自定义key (如果按照百度出来的key:mysql.version mysql.status mysql.ping的这样配置是错误导致无法启动zabbix-agent服务,可能是版本的原因吧),下面是正确配置:
UnsafeUserParameters=1
UserParameter=version,mysql -V
UserParameter=status[],/etc/zabbix/scripts/check_mysql.sh $1
UserParameter=ping[],mysqladmin -u zabbix -p123456 ping | grep -c alive
zabbix客户端的mysql脚本:
[root@mariadb02 zabbix]# cat scripts/check_mysql.sh
#!/bin/bash
source /etc/profile
用户名
#MYSQL_USER='zabbix'
密码
#MYSQL_PWD='123456'
主机地址/IP
#MYSQL_HOST='127.0.0.1'
端口
#MYSQL_PORT='3306'
数据连接
#mysqladmin=/usr/bin/mysqladmin -u${MYSQL_USER} -p${MYSQL_PWD} -h${MYSQL_HOST} -P${MYSQL_PORT}
mysqladmin=which mysqladmin
case $1 in
Uptime)
result=${mysqladmin} status|cut -f2 -d":"|cut -f1 -d"T"
echo $result
;;
Com_update)
result=${mysqladmin} extended-status |grep -w "Com_update"|cut -d"|" -f3
echo $result
;;
Slow_queries)
result=${mysqladmin} status |cut -f5 -d":"|cut -f1 -d"O"
echo $result
;;
Com_select)
result=${mysqladmin} extended-status |grep -w "Com_select"|cut -d"|" -f3
echo $result
;;
Com_rollback)
result=${mysqladmin} extended-status |grep -w "Com_rollback"|cut -d"|" -f3
echo $result
;;
Questions)
result=${mysqladmin} status|cut -f4 -d":"|cut -f1 -d"S"
echo $result
;;
Com_insert)
result=${mysqladmin} extended-status |grep -w "Com_insert"|cut -d"|" -f3
echo $result
;;
Com_delete)
result=${mysqladmin} extended-status |grep -w "Com_delete"|cut -d"|" -f3
echo $result
;;
Com_commit)
result=${mysqladmin} extended-status |grep -w "Com_commit"|cut -d"|" -f3
echo $result
;;
Bytes_sent)
result=${mysqladmin} extended-status |grep -w "Bytes_sent" |cut -d"|" -f3
echo $result
;;
Bytes_received)
result=${mysqladmin} extended-status |grep -w "Bytes_received" |cut -d"|" -f3
echo $result
;;
Com_begin)
result=${mysqladmin} extended-status |grep -w "Com_begin"|cut -d"|" -f3
echo $result
;;
*)
echo "Usage:$0(Uptime|Com_update|Slow_queries|Com_select|Com_rollback|Questions|Com_insert|Com_delete|Com_commit|Bytes_sent|Bytes_received|Com_begin)"
;;
esac
zabbix服务端的log日志