Linux проверить запущен ли mysql

How to check if MySQL server is working or not? [closed]

Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.

I have installed Webuzo on my unmanaged VPS. I am not able to install any applications, since it is giving me errors such «Unable to connect to MySQL server». But through terminal, the MySQL status is running.

Can anybody help how to troubleshoot?

I think it unlikely you’ll get much help here. Professional environments almost never use these sorts of «stacks» to deploy web applications; they are generally designed for developers and enthusiasts, people at the very end of the long tail, and people who don’t actually know how to administer a web site.

6 Answers 6

Many ways to do it — in your terminal:

sudo service mysql status

What you’re facing is probably authentication failure or database misspell.

Did you try logging in with same creds via Terminal?

Also check to what IP address the daemon is bound. Maybe you’re using the wrong one and that is the reason for the failure?

You can check the MySQL service status as follows :

`Root > service mysqld status

// Is MySQL listening to the required port

You can check the status of the MySQL service from the Webuzo Enduser Panel >> Services Menu. Guide : http://webuzo.com/wiki/Restart_services

As for your error «Unable to connect to MySQL server», are you able to create databases from the Webuzo Enduser Panel ? Guide : http://webuzo.com/wiki/How_to_Create_and_Manage_MySQL_Databases

Did you change the MySQL root users’ password ? Password for the MySQL root user is in the file /var/webuzo/my.conf

Читайте также:  Server in linux xampp

If the MySQL service is running, try accessing the MySQL server from the terminal.

Источник

Как узнать запущен ли mysql на centos и почему не работает ?

Здравствуйте, на сервере возникла какая-то ошибка, ниодин скрипт не может подключится к базам данных mysql — непонятно почему.

Последние сообщения в error log — такого вида — [Thu Jul 11 14:28:02 2013] [error] [client 178.35.200.37] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: адрес страницы сайта

Насколько я понимаю эти ошибки к mysql не относятся.

Перезагрузка сервера тоже результата на даёт. Даю команду ps — выдаётся среди прочих, такая строка. 1357 ? 00:13:21 mysqld_safe больше по mysql ничего нету.

Вроде процесс должен называться просто mysql ? Как теперь запустить БД ?

Последние сообщения в error log — такого вида — [Thu Jul 11 14:28:02 2013] [error] [client 178.35.200.37] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: адрес страницы сайта

А rewrite правила в апаче не менялись перед этим? судя по ошибке они корявые

Вот что выдало на ps aux | grep mysqld

root$ ps aux | grep mysqld root 300 0.0 0.1 6384 620 ? S 20:45 0:00 grep mysqld root 1357 56.3 2.7 120760 13896 ? S 19:08 54:55 /bin/sh /usr/bin/mysqld_safe —datadir=/var/lib/mysql —socket=/var/lib/mysql/mysql.sock —pid-file=/var/run/mysqld/mysqld.pid —basedir=/usr —user=mysql mysql 32765 21.0 2.6 161460 13072 ? R 20:45 0:00 /usr/libexec/mysqld —basedir=/usr —datadir=/var/lib/mysql —user=mysql —log-error=/var/log/mysqld.log —pid-file=/var/run/mysqld/mysqld.pid —socket=/var/lib/mysql/mysql.sock

Вот что выдало на pgrep mysql 1357

Вот что выдало на /etc/init.d/mysql status/restart/whatever -bash: line 13: /etc/init.d/mysql: No such file or directory

Извините я с линуксом не работал, так и непонял запущен ли сейчас mysql ? если нет, то как его запустить ? если запущен, то почему не подключаются скрипты ?

Читайте также:  Linux resize ntfs resize

Источник

Check MySQL Status Ubuntu

MySQL is one of the most popular and commonly used database management systems for web applications. It is simple to set up, configure and manage, making it one of the best choices for new and experienced users.

However, sometimes the MySQL server stops due to errors or misconfiguration. This guide will show you how to check the status of the MySQL server and start it if it is down. We will implement concepts such as systemd, crontab, and bash scripting to perform such action.

Pre-requisites

Before we begin, ensure that you have:

  • Installed and configured the MySQL server
  • Have access to root or account with sudo enabled

Once we have the above requirements, we can get started.

Check MySQL Status – Systemd

The first method we shall focus on before covering how to create a script is to use the systemd manager.

Systemd is a powerful Linux init system and service manager that allows starts, stops, and monitors the statuses of daemons and services. It additionally offers features such as logging and tracking usage, etc. Thus, it is a common tool for system administrators.

To use systemd to check for MySQL service, use the command as:

Once you execute the above command, then systemd will start the service assuming it does not run into any errors. To check the status of the service, use the command:

This will give you the output below showing the service is running.

Check MySQL Status – MySQLadmin

We can also use a tool such as mysqladmin. A MySQL server administration command-line utility to check the status of the MySQL server.

If the MySQL server is up and running, you will get output as shown below:

Uptime: 35 Threads: 1 Questions: 4 Slow queries: 0 Opens: 103 Flush tables: 3 Open tables: 24 Queries per second avg: 0.114

Bash Script

With the information we have of the two methods discussed above, we can implement a fairly simple bash script to check if the service is running and start it if it’s not.

Читайте также:  How to use file command in linux

Step 1: Check if the service is running
The first thing our script should do is to check if the service is running; we can get this from the output from systemd as:

Step 2: Redirect Standard Error to standard output
Once we grep for the status of the service, we can redirect the EOF to the /dev/null and a file descriptor as:

Step 3: Get Return Value
In the next step, we check the return value from the above command using the $?

Step 4: Putting it together
Now that we have the functionality of the script all laid out, we can put together the script as:

#!/bin/bash
systemctl status mysql.service | grep ‘active’ > /dev/null 2>&1
if [ $? != 0 ]
then
systemctl start mysql.service
fi

Now save the script and make it executable

Step 5: Tell Cron
And the last step for us to do is let cron know about our script and automatically manage it.

We can do this using the command:

Enter the following lines.

This will allow cron to run the script every 5 minutes and start the service.

Conclusion

In this tutorial, we used systemd to check for the status of MySQL and restart it. We also implemented a bash script and cron to check automatically handle the check and restart process.

As usual, thank you for reading and Happy Shells.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list

Источник

Оцените статью
Adblock
detector