Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install MySQL on Ubuntu Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to install MySQL on Ubuntu Linux, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

MySQL is a typical database management system. It is used in many technology stacks, including the popular LAMP (Linux, Apache, MySQL, PHP) technology stack. It has been proved to be stable. Another reason that makes MySQL popular is that it is open source.

MySQL is a relational database (basically tabular data). In this way, it is easy to store, organize, and access data. It uses SQL (structured query language) to manage data.

In this article, I will show you how to install and use MySQL 8.0 on Ubuntu 18.04. Let's have a look together.

Install MySQL on Ubuntu

I will show you two ways to install MySQL on Ubuntu 18.04:

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

Install MySQL from the Ubuntu repository. (5.7)

Install MySQL from the official warehouse. You will add a few extra steps to the process, but don't worry. You will have the current version of MySQL (8.0)

If necessary, I will provide screenshots to guide you. But for most of the steps in this article, I'll type commands directly into the terminal (default hotkey: CTRL+ALT+T). Don't be afraid!

Method 1. Install MySQL from Ubuntu warehouse

First, enter the following command to make sure that your warehouse has been updated:

Sudo apt update

Now, install MySQL 5.7and simply enter the following command:

Sudo apt install mysql-server-y

okay! Simple and efficient.

Method 2. Use the official warehouse to install MySQL

Although this method has a few more steps, I will introduce it one by one and try to take clear notes.

First, browse the download page of the official MySQL website.

Here, select the DEB package and click the "Download" link.

Slide to the bottom of the information about the Oracle website, right-click "No thanks, just start my download." and select "Copy link location".

Now back at the terminal, we will use the Curl command to download the package:

Curl-OL https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb

Https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb is the link I just copied from the web page. Depending on the current version of MySQL, it may be different. Let's use dpkg to start installing MySQL:

Sudo dpkg-I mysql-apt-config*

Update your warehouse:

Sudo apt update

To actually install MySQL, we will install it using the same command as in the previous method:

Sudo apt install mysql-server-y

Doing so will open a prompt for package configuration in your terminal. Use the down arrow to select the Ok option.

Click enter. This should prompt you for a password: this is setting the root password for MySQL. Don't be confused with Ubuntu's root password.

Enter the password and click the Tab key to select "Ok". Click enter and you will re-enter your password. When you are done, type Tab again to select "Ok". Press enter.

Some configuration information about MySQL Server will be displayed. Press Tab again to select "Ok" and press enter:

Here you need to select the default validation plug-in. Make sure "Use Strong Password Encryption" is selected. Press Tab and enter.

okay! You have successfully installed MySQL.

Verify your MySQL installation

To verify that MySQL is installed correctly, use the following command:

Sudo systemctl status mysql.service

This will show some information about the MySQL service:

You should see "Active: active (running)" there. If you don't see it, use the following command to start the service:

Sudo systemctl start mysql.service configuration / protection of MySQL

For the newly installed MySQL, you should run the security-related update commands it provides. That is:

Sudo mysql_secure_installation

Doing so will first ask you if you want to use password effective strength validate password component. If you want to use it, you will have to choose a minimum password strength (0-low, 1-medium, 2-high). You will not be able to enter any passwords that do not comply with the selected rules. This may come in handy if you are not in the habit of using strong passwords (which should have been used). If you think it might help, type y or Y, press enter, then select an intensity level for your password and enter a password you want to use. If successful, you will continue the enhancement process; otherwise you will re-enter a password.

However, if you don't want this feature (I won't), just press enter or any other key to skip it.

For other options, I recommend turning them on (enter y or Y for each step and press enter). They are: "remove anonymous user remove anonymous user", "disable root remote login to disallow root login remotely", "remove test database and its access remove test database and access to it". "reload permission table reload privilege tables now".

Link and disconnect MySQL Server

To run a SQL query, you must first connect to the server using MySQL and use it at the MySQL prompt.

The command to do this is:

Mysql-h host_name-u user-p

-h is used to specify a hostname (useful if the service is installed on another machine; if not, ignore it)

-u specify the user to log in

-p specify the password you want to enter.

Although it is not recommended for security reasons, you can enter the password directly after the-p on the rightmost side of the command line. For example, if the password for user test_user is 1234, you can try to connect on the machine you are using, and you can use:

Mysql-u test_user-p1234

If you successfully enter the necessary parameters, you will receive a welcome from the MySQL shell prompt (mysql >):

To disconnect from the server and leave the MySQL prompt, enter:

QUIT

Enter quit (MySQL is case-insensitive) or\ Q will work. Press enter to exit.

You can also output information about the version using simple commands:

Sudo mysqladmin-u root version-p

If you want to see a list of command line options, use:

Mysql-- help uninstalls MySQL

If you decide to use a newer version or just want to stop using MySQL.

First, shut down the service:

Sudo systemctl stop mysql.service & & sudo systemctl disable mysql.service

Make sure you back up your databases in case you want to use them later. You can uninstall MySQL by running the following command:

Sudo apt purge mysql*

Clean up dependencies:

Sudo apt autoremove after reading the above, do you know how to install MySQL on Ubuntu Linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report