Home  >  Article  >  Database  >  How to start mysql

How to start mysql

PHPz
PHPzOriginal
2023-05-11 19:03:3510273browse

MySQL is one of the most popular relational database management systems in the world. Many websites and applications use MySQL to store and manage data. This article will introduce how to start the MySQL service and how to manage the MySQL database.

1. Install MySQL

Before starting the MySQL service, you need to install MySQL first. If you have not installed MySQL, please follow these steps:

  1. Open a terminal or command prompt
  2. Enter the following command:
sudo apt-get update

This will Update your system package list to ensure your computer has the latest packages installed.

  1. Next, enter the following command to install MySQL:
sudo apt-get install mysql-server
  1. During the installation process, you will be prompted to create a password for the MySQL root user. Please note that this is very important. Please make sure you use a strong password to protect your database.

2. Start the MySQL service

Once you have completed the installation of MySQL, you need to start the MySQL service to start using it. The method of starting the MySQL service may vary depending on the operating system and MySQL version. Here are some common ways to start the MySQL service:

  1. In a Linux system, you can enter the following command to start MySQL:
sudo service mysql start

This will start the MySQL service, and make it start automatically when the operating system starts.

  1. In Mac operating system, you can follow the steps below:

a. Open the terminal

b. Enter the following command to start the MySQL service :

sudo /usr/local/mysql/support-files/mysql.server start
  1. In Windows system, you can follow the steps below:

a. Click the "Start" button

b. Search for "services .msc" and open it

c. Find the "MySQL" service and start it

3. Manage MySQL database

Once you have started the MySQL service, you can use MySQL A command line interface or other graphical user interface (such as phpMyAdmin) to manage your database. The following are some commonly used MySQL database management methods:

  1. Command Line Management

Open a terminal or command prompt and use the following command to connect to MySQL:

mysql -u username -p

Where username is your MySQL username. After entering this command, you will be prompted for your MySQL user password.

Once you are connected to MySQL, you can use the following command to manage your database:

a. Create a new database:

CREATE DATABASE database_name;

Where database_name is the value you want The name of the database created.

b. Delete a database:

DROP DATABASE database_name;

where database_name is the name of the database you want to delete.

c. Create a new user:

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

where username is the username you want to create, and password is the password you want to set.

d. Grant user access permissions:

GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';

Where database_name is the name of the database to which you want to grant permissions, and username is the user name to which you want to grant permissions.

e. List all databases:

SHOW DATABASES;
  1. phpMyAdmin Management

If you prefer to use a graphical user interface to manage MySQL databases, you can try Use phpMyAdmin. phpMyAdmin is a web-based MySQL management tool that helps you manage MySQL databases easily.

To use phpMyAdmin, you need to follow these steps to install it:

a. Open a terminal or command prompt

b. Enter the following command to install phpMyAdmin:

sudo apt-get install phpmyadmin

c. During the installation process, you will be prompted to set the administrator password for phpMyAdmin. Please make sure you use a strong password to protect phpMyAdmin.

Once you have installed phpMyAdmin, you can access it through a web browser and use it to manage your MySQL database.

4. Summary

In this article, we introduced how to start the MySQL service and some common methods for managing the MySQL database. MySQL is a powerful and widely used database management system, and learning how to use it is extremely valuable. I hope this article will help you start and manage MySQL services.

The above is the detailed content of How to start mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn