Create the Initial Database
Video Lecture
Description
The commands executed in this video are,
1 | mysql -uroot -p |
Note
If you get an error that MySQL is not installed, or you can't connect through the socket, see the section below, Installing MySQL first.
Then press enter if you have no password or type the root password if you've set one.
1 | create database zabbix character set utf8 collate utf8_bin; |
1 | create user zabbix@localhost identified by 'password'; |
1 | grant all privileges on zabbix.* to zabbix@localhost; |
1 | quit; |
Import the schema,
1 | zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
|
Then press enter if you have no password or type the root password if you've set one.
Wait about 30 seconds for it to finish,
Then edit the Zabbix Server configuration file and set the DBPassword property to being password or the password that you set earlier
1 | sudo nano /etc/zabbix/zabbix_server.conf |
1 2 3 | ... DBPassword=password ... |
Note
I use nano, you can also use vim or many other text editors. If nano is not already installed on your OS, then on Ubuntu run sudo apt install nano
, and on Centos run yum install nano
Installing MySQL
If mySQL is not already setup on your OS, you can install it by following the instructions.
Ubuntu 18
1 2 3 | sudo apt install mysql-server sudo mysql_secure_installation |
You can select Y as the answer for all questions.
1 | sudo service mysql status |
It should now indicate that MySQL is now active. You can continue with this lecture.
Centos 7
1 2 3 4 5 6 7 8 9 | yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum install mysql-community-server
sudo systemctl start mysqld
sudo systemctl status mysqld
sudo grep 'temporary password' /var/log/mysqld.log
|
take note of the password, you will need it in the next step
1 | sudo mysql_secure_installation |
You will be required to enter a new password, so enter a new 12-character password that contains at least one uppercase letter, one lowercase letter, one number and one special character.
You can select Y as the answer for all questions during the MySQL Secure Installation phase.
Troubleshooting
Access denied for user 'zabbix'@'localhost'
Q. You get the error "ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: NO)"
A. When you set up the database, you logged into mysql using root
mysql -uroot -p
You then entered some commands,
create database zabbix character set utf8 collate utf8_bin;
This created a zabbix database
You then added a user called zabbix with the password password
.
create user zabbix@localhost identified by 'password';
You then granted all privileges to the zabbix user for the zabbix database
grant all privileges on zabbix.* to zabbix@localhost;
When you imported the schema, it runs it using the zabbix user and zabbix database. See the bit after the pipe symbol |
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
When you run the zcat command, you are prompted for a password. Use the zabbix
user password. In my example, the password is password
.
The server requested authentication method unknown to the client
Q. When logging into Zabbix for the first time, you are asked to enter the database connection details, you put in the complicated password, and you get the error "The server requested authentication method unknown to the client."
A. This is possibly due to the PHP front end not being aware if the MYSQL password hashing requirement. So you can alter the Zabbix user in the database to use the mysql_native_password
option.
Log into the mysql prompt as the root
1 | mysql |
Alter the zabbix user
1 2 | ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your-really-complicated-password-for-the-zabbix-user'; FLUSH PRIVILEGES; |
And restart MySQL
1 | sudo service mysql restart |