Starting mysql linux command

How to Start, Stop, and Restart MySQL Server

When using MySQL, there are times when it’s important to know how to start, stop, or restart your MySQL server. Luckily, there are multiple, easy ways to do this. Which methods are available to you however, will depend on the operating system your running.

Read on to learn how to start, stop, and restart MySQL server in both Linux and Windows.

How to Start, Stop, and Restart MySQL Server in Linux

If you need to stop or restart your MySQL server on a Linux system, there are three different commands that can be used:

  1. Depending on your Linux distribution, you can change the state of MySQL using the service command.
    • To start MySQL server:

      sudo service mysqld start

    • To stop MySQL server:

      sudo service mysqld stop

    • To restart MySQL server:

      sudo service mysqld restart

  2. If you don’t have the service command available or would prefer to make changes to MySQL using a different method, you can also use the init.d command to start/stop your MySQL server.
    • To start MySQL server:

      sudo /etc/init.d/mysqld start

    • To stop MySQL server:

      sudo /etc/init.d/mysqld stop

    • To restart MySQL server:

      sudo /etc/init.d/mysqld restart

  3. Lastly, you can also use the systemctl command to start, stop, and restart applications on Linux, including MySQL.
    • To start MySQL server:

      sudo systemctl start mysqld

    • To stop MySQL server:

      sudo systemctl stop mysqld

    • To restart MySQL server:

      sudo systemctl restart mysqld

How to Start, Stop, and Restart MySQL Server in Windows

If you’re trying to start, stop, or restart your MySQL server on a Windows-based system, you can do so easily from the command line. Just follow these 3 steps:

  1. To start, you’ll first need to open a terminal window. If you don’t have this somewhere easily accessible, you can find it quickly using the Windows’ Run dialog. To open the Run dialog, just press the Windows Key + R .
  2. Next, type in “ cmd ” and press the Enter key. This will open a new terminal window.
  3. Once you’ve opened a terminal window, just type the following commands to start or stop MySQL server:
    • To start MySQL server:

      mysqld start

    • To stop MySQL server:

      mysqld stop

*Note: depending on which version of Windows you are running, you may need the specific name of the MySQL version number you are running in order to start or stop the service. To find this, go to the start menu and search for Services . Locate the version of MySQL you are using and try the following commands, replacing “##” with your version number:

net start MySQL##

net stop MySQL##

For instance, if you’re running MySQL 8.0, replace “MySQL##” with “MySQL80”.

And there you have it! You now have several different methods for starting, stopping, and restarting MySQL server as needed.

Looking for more information on MySQL ? Search our Knowledge Base !

Interested in more articles about Databases ? Navigate to our Categories page using the bar on the left or check out these popular articles:

Popular tags within this category include: MySQL , MSSQL , phpMyAdmin , PostgreSQL , and more.

Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.

The Hivelocity Difference

Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.

With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.

Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.

Источник

How do I start/stop mysql server?

I tried to find in some articles describing how to correctly start & stop mysql server. I found this link: How to start/stop MySql server on Ubuntu 8.04 | Abhi’s Blogging World I ran this command:

ERROR 1045 (28000) Access denied for user. 
sudo /etc/init.d/mysql - root -p start 
ERROR 1049 (42000) Unknown database 'start'. 

MySQL server success started. Cool! So, what’s wrong with the other commands? Why do they result in error?

In fact, even with sudo it didn’t work for me, but then I found in the script the following hint: Rather than invoking init scripts through /etc/init.d, use the service(8) and it was ok

Generally you can use sudo -l to see what your specific user on your specific system is allowed to do with sudo. (Your permissions are configured in /etc/sudoers.) However I don’t know for sure if it would help in this particular case. EDIT: Wait, never mind, the access denied error looks like it is coming from MySQL or something, not sudo.

11 Answers 11

Your first two commands weren’t run as root so that is expected behaviour. You need to be root to stop/start mysql.

should work. Indeed it does, for me:

kojan:~> sudo /etc/init.d/mysql restart [sudo] password for chris: Stopping MySQL database server: mysqld. Starting MySQL database server: mysqld. Checking for corrupt, not cleanly closed and upgrade needing tables.. 

I used restart rather than start, since it was already running, but the effect is the same. Are you sure you entered your password correctly? 🙂 Have you edited your sudo config at all which would stop this working?

sudo /etc/init.d/mysql - root -p start 

The arguments are wrong. an init.d script only takes start or stop or restart — just one word telling it what to do. You cannot give it multiple arguments as you were trying to do.

Anyway, the short answer is the one you actually got to work, is the recommended way. service is replacing all the init.d scripts over time, so you should get into the habit of using service . The page you link to was written in 2008, so has to be taken with some salt 🙂

Источник

How to Start, Stop, and Restart MySQL Server in Linux Ubuntu

Start, stop, or restart your MySQL server; In this tutorial, you will learn three different methods to start, stop and restart mysql server on linux ubuntu using command line.

How to Start, Stop, and Restart MySQL Server in Linux Ubuntu

Using Service Command

If you are using service distribution of MySQL, so you need to run the following service command to start, stop and restart of your MySQL server on Linux ubuntu using command line:

To start MySQL server:

sudo service mysqld start

To stop MySQL server:

To restart MySQL server:

sudo service mysqld restart

Using init/d Command

If you are using init/d distribution of MySQL, so you need to run the following init/d command to start, stop and restart of your MySQL server on Linux ubuntu using command line:

To start MySQL server:

sudo /etc/init.d/mysqld start

To stop MySQL server:

To restart MySQL server:

sudo /etc/init.d/mysqld restart

Using systemctl Command

If you are using systemctl distribution of MySQL, so you need to run the following systemctl command to start, stop and restart of your MySQL server on Linux ubuntu using command line:

To start MySQL server:

sudo systemctl start mysqld

To stop MySQL server:

sudo sudo systemctl stop mysqld

To restart MySQL server:

sudo systemctl restart mysqld

Conclusion

That’s all; In this tutorial, you have learned three different methods to start, stop and restart MySQL server on Linux ubuntu using command line.

Источник

How To Start, Stop and Restart MySQL Server?

How To Start, Stop Or Restart A MySQL Server

There are several ways to start, stop and restart the MySQL server depending upon the operating system you are using. In this tutorial, we’ll learn how to start-stop and restart MySQL servers in windows, mac, and Linux operating systems.

Start, Stop and Restart MySQL Server on Windows

There are 3 ways by which you can perform these tasks on the MySQL server on Windows:

We’ll learn all three methods one by one:

Using services.msc

Step 1: On the keyboard press Windows, Type run on the search area, and click on open:

Open Run

Step 2: Type Services.msc on run and click on OK:

Open Services Folder

Step 3: Search for MySQL under the name column, Please keep in mind that the numeric extension after MySQL, as in the below example is MySQL80 may vary depending on the version of MySQL installed on your desktop. You can click on the MySQL80 section and a section on the left-hand side will be available to you with all the operations you can perform on that service.

MySQL Server On Services Folder

Step 4: Currently MySQL server is running, you can either choose to start, stop and restart the service from the left-hand side panel by selecting any of the options, or you can right-click on MySQL80 service and restart or stop the MySQL server from there.

Start Stop Or Restart MySQL Service Using Services 1

That’s how you can start, stop or restart the MySQL server in windows using services.

Using Windows Command Line

Step 1: Open Command Prompt, you can open it by pressing the Windows key on your keyboard and typing cmd on the search area.

Open Command Prompt

Step 2: Start, stop or restart the MySQL server.

To stop the MySQL server you can type the following command:

net stop MySQL80Code language: SQL (Structured Query Language) (sql)

To start the MySQL server you can type the following command:

net start MySQL80Code language: SQL (Structured Query Language) (sql)

Using MySQL Workbench

Step 1: Press the Windows key on your keyboard, type MySQL Workbench on the search bar, and open MySQL Workbench.

Open MySQL Workbench And Connecting To MySQL Instance

Step 2: Select the Administrator tab, in the Instances section select the Startup/Shutdown section.

Select Startup Shutdown

Step 3: You can start or stop the server in this window.

Start Or Stop The Server

These are the three ways, you can use to start or stop of MySQL server.

Start, Stop and restart MySQL Server on Linux

For performing these activities on Linux, you must be a superuser as only the superuser has these privileges.

Step 1: Open your Linux terminal and we need to check if MySQL is running on your operating system or not. To do so, we’ll need to type the following command:

service mysqld statusCode language: Bash (bash)

If MySQL is properly configured on your OS then the command will return Active status as Active(running) which means that MySQL is running on your operating system.

Step 2: Start, stop or restart MySQL

There will be two commands, service and sudo, both should work properly, but it depends if you have the privilege to use the service or sudo command on Linux. Make sure that you are a root user or a super user to perform the activity on MySQL.

To stop the MySQL server on Linux, use the following command:

service mysqld stop sudo /etc/init.d/mysql stopCode language: Bash (bash)

The above command will stop the MySQL server. Now if you will try to check again for the MySQL status it will show inactive(dead) on the active status.

To Start the MySQL server on Linux, use the following command:

service mysqld start sudo /etc/init.d/mysql startCode language: Bash (bash)

The above command will start the MySQL server. Now, if you will try to check again for the MySQL status it will again be active(running) on the active status.

To restart the MySQL server on Linux, use the following command:

service mysqld restart sudo /etc/init.d/mysql restartCode language: Bash (bash)

The above command will restart the MySQL server. Now, if you will try to check again for the MySQL status it will again be active(running) on the active status because we restarted the server.

Start, Stop or Restart MySQL Server on macOS

Open terminal on your Mac, we’ll be using the Sudo command to start, stop or restart the MySQL server.

For MySQL versions which are newer than 5.7:

To start MySQL server on Mac:

sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plistCode language: Bash (bash)

To Stop MySQL server on Mac:

sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plistCode language: Bash (bash)

For versions older than MySQL 5.7:

To Start MySQL server on Mac:

sudo /usr/local/mysql/support-files/mysql.server startCode language: Bash (bash)

To Stop MySQL server on Mac:

sudo /usr/local/mysql/support-files/mysql.server stopCode language: Bash (bash)

To Restart MySQL server on Mac:

sudo /usr/local/mysql/support-files/mysql.server restartCode language: Bash (bash)

Conclusion

Mysql is a powerful database management system. In order to use it effectively, you need to be familiar with the different ways to start, stop and restart it. By following the instructions in this article, you should be able to do just that. Thank you for reading!

Источник

Читайте также:  Intel r wireless ac 9560 linux
Оцените статью
Adblock
detector