World war 2 Pt 1

World war 2 was no doubt a significant moment in human history, it brought human cruelty to light and it also caused an explosion of ideals. Many ask whether it could have been avoided and in truth…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Enabling MySQL Logs In The Linux Environment

The MySQL log file is a collection of records of actions taken. The MySQL server creates log files based on the activities that are taken. General query logs, error logs, ISAM logs, binary logs, update logs, and sluggish query logs are all examples of log files.

This blog post describes how to enable General logs, error logs, and Slow query logs in the Linux environment. I used CentOS 7 to do this task.

Ok…. Let’s Start

The general query log is a general record of what MySQL Server is doing.

It’s consists of :

Here you can check the general logs are already enabled or disabled using the below query. After login into the MySQL server, you can execute this query.

show variables like ‘%general%’;

Default Location Of General Logs

First, stop the MySQL service using this command,

systemctl stop mysqld

Then create the log file in a particular location. eg:- /var/lib/mysql, (you can use any name and any location)

touch linux2.log

After that give the file permission to the above-created file using the below command.

chmod 777 linux2.log

Now you can get the created linux2.log file path using pwd command. Then copy the path of the created linux2.log file to the relevant place of my.cnf file.

/var/lib/mysq/linux2.log

Then go to this location (/etc/my.cnf) to access MySQL configuration file.

The my.cnf file content is like this,

Content of my.cnf

In this file, we should modify this area like this.

[mysqld]

After these configurations, you should start the MySQL service.

systemctl start mysqld

Then go to the MySQL server using the below command.

mysql -u root -p

Now you should edit your database. After that look at the created log file (linux2.log) using the cat command. Now you can see the access logs, modification logs, queries, etc, related to server-side activities.

General Log

The error log contains a record of mysqld startup and shutdown times. It also contains diagnostic messages such as errors, warnings, and notes that occur during server startup and shutdown, and while the server is running.

Here you can check the details of the error logs using the below query. After login into the MySQL server, you can execute this query.

show variables like ‘%error%’;

As the result of the above query, you can see, the default location of storing Error logs and more.

Default Location Of Error Logs

First, stop the MySQL service using this command,

systemctl stop mysqld

Then create the log file in a particular location. eg:- /var/lib/mysql, (you can use any name and any location)

touch errorlogsql.log

After that give the file permission to the above-created file using the below command.

chmod 777 errorlogsql.log

Now you can get the created errorlogsql.log file path using pwd command. Then copy the path of the created errorlogsql.log file to the relevant place of my.cnf file.

/var/lib/mysq/errorlogsql.log

Then go to this location (/etc/my.cnf) to access MySQL configuration file and then add these configurations.

[mysqld]

log-error= /var/lib/mysql/errorlogsql.log

After these configurations, you should start the MySQL service.

systemctl start mysqld

Then go to the MySQL server.

mysql -u root -p

Now you should create an error related to your MySQL server. After that read the created error log file (errorlogsql.log) using the cat command. Now you can see the errors and Warnings related to server-side activities.

Error Logs

The MySQL slow query log is where the MySQL database server registers all queries that exceed a given threshold of execution time. This can often be a good starting place to see which queries are slowest and how often they are slow.

Slow queries might indicate that your database is doing more work than it needs to, which implies it is consuming more resources. Everything can start to slow down when restricted resources, such as CPU or I/O, run out. When you don’t utilize the resources you have, inefficient resource usage becomes an issue.

Here you can check that the slow query logs are already enabled or disabled using the below query. After login into the MySQL server, you can execute this query.

As the result of the above query, you can see, the default location of storing slower query logs and already enabled or disabled the slower query logs as below figure.

Default Location Of Slow query logs

First, stop the MySQL service using this command,

systemctl stop mysqld

Then create the log file in a particular location. eg:- /var/lib/mysql, (you can use any name and any location)

touch slow-mysql-query.log

After that give the file permission to the above-created file using the below command.

chmod 777 slow-mysql-query.log

Now you can get the created slow-mysql-query.log file path using pwd command. Then copy the path of the created slow-mysql-query.log file to the relevant place of my.cnf file.

/var/lib/mysq/slow-mysql-query.log

Then go to this location (/etc/my.cnf) to access MySQL configuration file.

Then go to this location (/etc/my.cnf) to access MySQL configuration file and then add these configurations.

[mysqld]

After these configurations, you should start the MySQL service.

systemctl start mysqld

Then go to the MySQL server.

mysql -u root -p

Now you should execute some slow-running queries on the MySQL server. After that look at the created slow-query.log file (slow-mysql-query.log) using the cat command. Now you can see the slow query logs related to server-side activities.

More resources :

Add a comment

Related posts:

Genesis Global is Optimistic it Can Resolve Creditor Disputes This Week

A lawyer representing Genesis Global Capital believes that the crypto lender could resolve its disputes with creditors this week and eventually exit Chapter 11 bankruptcy by late May. Creditors of…

The SEC Kills Crypto Exchanges

It was only a matter a of time. There were clearly signs this was going to happen already out there when the SEC went after defunct “exchange” BitFunder. Today, the SEC made its biggest announcement…

How a business can kick out microplastics

The Swedish online pharmacy Apotea.se used to market more than 200 products containing microplastics. Today the number is zero. Here’s how it happened. Sustainability expert Tove Ahlström has long…