- How do I start a MySQL server on Windows?
- 5 Answers 5
- METHOD #1: Access the Installed Service
- METHOD #2: Command Line Execution
- Give it a try.
- Перезапуск MySQL
- Перезапуск MySQL или MariaDB
- Автоматический перезапуск MySQL
- Выводы
- Restart mysql server windows
- Restart mysql server windows
- TablePlus
- How to start, stop, and restart MySQL database server?
How do I start a MySQL server on Windows?
I’ve installed a MySQL server onto my computer and when I first installed it, it ran automatically. Now I’ve restarted my computer it is no longer running. What file do I need to run to get it back up and running again?
I’ve tried running MySQL 5.6 Command Line Client and mysqld.exe from the Program Files/MySQL/MySQLServer/bin directory, and I’ve had no luck.
Upon running mysqld.exe, I get the following error:
Naturally, I tried running it as administrator, and I got this:
5 Answers 5
Make sure the mysqld.exe is ticked under the Startup tab when you go to run and type msconfig . Also, same goes for Services , look for the MySQL services there, right click > properties and make sure the startup types are selected as automatic.
If you installed MySQL using the MSI installer, it should be set up as a service.
You can open the service in two ways
METHOD #1: Access the Installed Service
- Open up the Services icon in the Control Panel
- Scroll alphabetically to the MySQL service
- Right click the service
- Click Start Service
METHOD #2: Command Line Execution
- Open DOS Window
- From the C: Prompt, run this: net start mysql or ‘net start mysql57’. The right name may vary on your system
If you get this error
then you didn’t run the DOS Window as Administrator. Try again as administrator. You should see:
Give it a try.
I had the similar issue and found later that the encoding of my.ini file changes if you open that from notepad. Open the file from Notepad++ and make sure to take a note of the .ini file encoding (mostly it is UTF-8). If the file encoding changes SQL service will not start. Make sure that the new directory in which the data path is set has permissions for the account that runs the mySQLd service in windows (mostly it is network service).
If you are using wamp on windows, you can start mysql from command line by :
This assumes that you have installed wamp at the root
In order to start manually the mysql serve you must run the mysqld executable. Open the command prompt and type:
If mysqld doesn’t start, check the error log. The error log is located in the C:\Program Files\MySQL\MySQLServer\data. It is the file with a suffix of .err. You can also try to start the server as mysqld —console; in this case, you may get some useful information on the screen that may help solve the problem.
Перезапуск MySQL
MySQL — это самая популярная система баз данных, которая используется для обеспечения работы большинства сайтов. Пока вы размещаете свой сайт на хостинге, вам нет необходимости думать о её настройке или своевременной перезагрузке, потому что этим занимаются системные администраторы хостинга. Но когда вы переберётесь на VPS, это всё будет уже в зоне вашей ответственности.
В этой статье мы рассмотрим, как выполняется перезапуск MySQL в разных дистрибутивах Linux, а также как сделать, чтобы MySQL перезапускалась автоматически после падения.
Перезапуск MySQL или MariaDB
В большинстве современных дистрибутивов, а особенно тех, что используются для работы серверов, для управления службами применяют Systemd. Именно с её помощью мы будем перезапускать движок баз данных. Ещё один момент, с которым нужно определиться, — это название юнит-файла MySQL. В зависимости от версии и дистрибутива оно может отличаться:
Вы можете попробовать использовать эти варианты, чтобы найти тот, что используется в вашей системе; последние версии Ubuntu понимают несколько имен MySQL. Таким образом, для MariaDB и выше перезапуск MySQL Сentos и Ubuntu не отличается. Просто попробуйте узнать состояние сервиса, если вы выбрали правильное название, то увидите что-то вроде этого:
Выполнить частичную перезагрузку только с обновлением конфигурации, так как это делалось в Apache и Nginx вы не сможете. Здесь необходимо полностью перезагружать сервис:
sudo systemctl restart mysql
В некоторых случаях необходимо полностью остановить работающий сервис, а потом запустить его заново. Для этого используем команду stop, затем start:
sudo systemctl stop mysql
sudo systemctl start mysql
Автоматический перезапуск MySQL
Из-за проблем с памятью на сервере или других ошибок MySQL может завершить свою работу. Это очень неприятное обстоятельство, поскольку вы не можете всегда следить за сервером, а когда такое случиться, ваш сайт будет недоступен для пользователей на протяжении долгого времени.
В systemd есть возможность, которая позволяет делать рестарт MySQL сразу же после того, как он неожиданно завершился. Для этого необходимо добавить такую строчку в конфигурацию юнит-файла MySQL:
Но обратите внимание, что редактировать файлы юнитов в папке /usr нельзя, потому что во время обновления они могут быть перезаписаны, можно только в /etc, и желательно создавать отдельный файл. Можно поступить проще: используйте команду systemctl edit:
sudo systemctl edit mariadb
Сохраните изменения. Эти строки будут записаны в виде отдельного файла, который автоматически подключается к основному.
Выводы
В этой статье мы рассмотрели, как перезапустить MySQL для обновления конфигурации, а также как настроить автоматический перезапуск службы после возникновения ошибок. Если у вас остались вопросы, спрашивайте в комментариях!
Restart mysql server windows
The MySQL server can be started manually from the command line. This can be done on any version of Windows.
To start the mysqld server from the command line, you should start a console window (or “ DOS window ” ) and enter this command:
The path to mysqld may vary depending on the install location of MySQL on your system.
You can stop the MySQL server by executing this command:
If the MySQL root user account has a password, you need to invoke mysqladmin with the -p option and supply the password when prompted.
This command invokes the MySQL administrative utility mysqladmin to connect to the server and tell it to shut down. The command connects as the MySQL root user, which is the default administrative account in the MySQL grant system.
Users in the MySQL grant system are wholly independent from any operating system users under Microsoft Windows.
If mysqld doesn’t start, check the error log to see whether the server wrote any messages there to indicate the cause of the problem. By default, the error log is located in the C:\Program Files\MySQL\MySQL Server 8.0\data directory. It is the file with a suffix of .err , or may be specified by passing in the —log-error option. Alternatively, you can try to start the server with the —console option; in this case, the server may display some useful information on the screen to help solve the problem.
Restart mysql server windows
This statement stops and restarts the MySQL server. It requires the SHUTDOWN privilege.
One use for RESTART is when it is not possible or convenient to gain command-line access to the MySQL server on the server host to restart it. For example, SET PERSIST_ONLY can be used at runtime to make configuration changes to system variables that can be set only at server startup, but the server must still be restarted for those changes to take effect. The RESTART statement provides a way to do so from within client sessions, without requiring command-line access on the server host.
After executing a RESTART statement, the client can expect the current connection to be lost. If auto-reconnect is enabled, the connection is reestablished after the server restarts. Otherwise, the connection must be reestablished manually.
A successful RESTART operation requires mysqld to be running in an environment that has a monitoring process available to detect a server shutdown performed for restart purposes:
In the presence of a monitoring process, RESTART causes mysqld to terminate such that the monitoring process can determine that it should start a new mysqld instance.
If no monitoring process is present, RESTART fails with an error.
These platforms provide the necessary monitoring support for the RESTART statement:
Windows, when mysqld is started as a Windows service or standalone. ( mysqld forks, and one process acts as a monitor to the other, which acts as the server.)
Unix and Unix-like systems that use systemd or mysqld_safe to manage mysqld .
To configure a monitoring environment such that mysqld enables the RESTART statement:
Set the MYSQLD_PARENT_PID environment variable to the value of the process ID of the process that starts mysqld , before starting mysqld .
When mysqld performs a shutdown due to use of the RESTART statement, it returns exit code 16.
When the monitoring process detects an exit code of 16, it starts mysqld again. Otherwise, it exits.
Here is a minimal example as implemented in the bash shell:
On Windows, the forking used to implement RESTART makes determining the server process to attach to for debugging more difficult. To alleviate this, starting the server with —gdb suppresses forking, in addition to its other actions done to set up a debugging environment. In non-debug settings, —no-monitor may be used for the sole purpose of suppressing forking the monitor process. For a server started with either —gdb or —no-monitor , executing RESTART causes the server to simply exit without restarting.
The Com_restart status variable tracks the number of RESTART statements. Because status variables are initialized for each server startup and do not persist across restarts, Com_restart normally has a value of zero, but can be nonzero if RESTART statements were executed but failed.
TablePlus
How to start, stop, and restart MySQL database server?
October 29, 2018
In this post, we are going to see how to start, stop, and restart MySQL Server on macOS, Linux, and Windows.
1. On Mac
You can start/stop/restart MySQL Server via the command line.
- For the version of MySQL older than 5.7:
- For the MySQL version 5.7 and newer:
- Or you can turn it on/off via the macOS Preference Panel
There’s another way which you can use DBngin, an free utility to install and manage multiple database servers on Mac.
- To turn on/off, it’s just one click away from the server control panel:
2. On Linux
- On Linux start/stop from the command line:
- Some Linux flavours offer the service command too
3. On Windows
- Open Run Window by Winkey + R
- Type services.msc
- Search MySQL service based on version installed.
- Click stop, start or restart the service option.
Or you can start/stop MySQL from the command prompt:
Need a good GUI tool for MySQL on MacOS and Windows? TablePlus is a modern, native tool with an elegant GUI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server and more.