Create the Initial Database
Video Lecture
Description
I need to install a MySQL database.
To check if you have a MySQL database server running, you can type
# |
|
or
# |
|
If you get the error
Unit mysql.service could not be found.
or
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
Then it most likely means that the MySQL database service is not installed.
So in my case, since I have a brand-new server, and it doesn't have a MySQL server installed by default, I need to install a MySQL server.
# |
|
Check if it is running.
# |
|
It should now indicate that MySQL is active.
Create Zabbix User and Database
We can now log onto the MySQL server and set up the Zabbix database and its user.
# |
|
mysql> |
|
mysql> |
|
mysql> |
|
Warning
Since August 2022, we now need to temporarily enable the log_bin_trust_function_creators
option.
mysql> |
|
mysql> |
|
Import Zabbix Schema
Now, import the Zabbix schema.
# |
|
If prompted, enter the password that you've set for your zabbix@localhost
user.
Wait about 30 seconds for it to finish.
Now to disable the log_bin_trust_function_creators
option.
# |
|
mysql> mysql> |
|
Edit Zabbix Server configuration file
Now in the Zabbix Server configuration file, find and set the DBPassword
property to being the password that you set for your zabbix@localhost
user.
# |
|
DBPassword=password
Do some MySQL checks if you want.
# |
|
mysql> |
|
mysql> |
|
mysql> |
|
mysql> |
|
mysql> |
|
Start the Zabbix Server Process
Now that MySQL is running, we can start the Zabbix Server process.
# |
|
And check its status is active
# |
|
To ensure that Zabbix Server, Agent and Apache restart in case of reboot, run this command.
# |
|
Troubleshooting
ERROR : SET PASSWORD has no significance for user 'root'@'localhost'
mysql_secure_installation
stopped working since MySQL version 8.0.29.
I no longer recommend running this command.
But if you want to, then before running mysql_secure_installation
, you can enter the MySQL prompt
# |
|
Alter the localhost root user
mysql> mysql> |
|
Exit
mysql> |
|
And now run
# |
|
Note that when using the MySQL prompt from now on, you now need to enter the password
I.e. start MySQL prompt using,
# |
|
instead of just
# |
|
ERROR : You do not have the SUPER privilege and binary logging is enabled
Since August 2022, you need to modify the MySQL log_bin_trust_function_creators
flag in order to install the Zabbix server database schema.
If you followed my above commands but didn't enable the log_bin_trust_function_creators
option, then we need to drop
the new Zabbix database from our new MySQL server.
# |
|
mysql> |
|
Now re-create it.
mysql> |
|
If your zabbix@localhost
user doesn't already exist from the earlier install attempt, then
mysql> |
|
Re grant all privileges of the new Zabbix database to your Zabbix database user.
mysql> |
|
This next step is now required since August 2022.
mysql> |
|
Quit as usual.
mysql> |
|
Now go back and continue the installation steps above where we need to try and re-import the schema.