您好,登錄后才能下訂單哦!
新安裝的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_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’, 這可以允許全部可以訪問
#
#
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
[...]
Server=127.0.0.1
[...]
ServerActive=127.0.0.1
[...]
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'
#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日志
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。