One article explains how to install MySQL with yum on Linux/UNIX

藏色散人
Release: 2021-09-25 17:08:46
forward
1916 people have browsed it

The following column linux system tutorial will introduce to you how to install MySQL on yum on Linux/UNIX. I hope it will be helpful to friends in need!

Install MySQL on yum on Linux/UNIX

It is recommended to use RPM package for installation on Linux platform Mysql, MySQL AB provides the download address of the following RPM package:

  • MySQL-MySQL server. You need this option unless you only want to connect to a MySQL server running on another machine.
  • MySQL-client- MySQL client program, used to connect to and operate the Mysql server.
  • MySQL-devel- Libraries and include files, if you want to compile other MySQL clients, such as Perl modules, you need to install this RPM package.
  • MySQL-shared- This package contains shared libraries (libmysqlclient.so*) that some languages ​​and applications need to dynamically load using MySQL.
  • MySQL-bench - Benchmark and performance testing tool for MySQL database servers.

Before installation, we can check whether the system comes with MySQL installed:

rpm -qa | grep mysql
Copy after login

If your system has it installed, you can choose to uninstall it:

rpm -e mysql  // 普通删除模式 
rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
Copy after login

Install the official Version

Next we use the yum command to install MySQL under the Centos7 system. It should be noted that the MySQL database has been removed from the default program list in the CentOS 7 version, so we need to download it from the official website before installation. Yum resource package, the download address is: https://dev.mysql.com/downloads/repo/yum/

Note: We need to enable administrator rights to install during the installation process. Otherwise, the installation will fail due to insufficient permissions.
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server
Copy after login

Permission settings:

chown mysql:mysql -R /var/lib/mysql
Copy after login

Initialize MySQL:

mysqld --initialize
Copy after login

Start MySQL:

systemctl start mysqld
Copy after login

View MySQL running status:

systemctl status mysqld
Copy after login

Note: If we start the mysql service for the first time, the mysql server will first perform initial configuration.

Install the community version

In addition, you can also use MariaDB instead. The MariaDB database management system is a branch of MySQL, which is mainly maintained by the open source community and is licensed under the GPL. One of the reasons for developing this branch is that after Oracle acquired MySQL, there was a potential risk of MySQL being closed source, so the community adopted a branch approach to avoid this risk.

MariaDB aims to be fully compatible with MySQL, including API and command line, making it an easy replacement for MySQL.
yum install mariadb\-server mariadb
Copy after login

The relevant commands for the mariadb database are:

systemctl start mariadb #启动MariaDB 
systemctl stop mariadb #停止MariaDB 
systemctl restart mariadb #重启MariaDB 
systemctl enable mariadb #设置开机启动
Copy after login

Verify MySQL installation

After successfully installing MySQL, some basic tables will be initialized. After the server starts, you can Verify that MySQL is working properly with a simple test.

Use the mysqladmin tool to get the server status:

Use the mysqladmin command to check the server version. On Linux, the binary file is located in the /usr/bin directory. On Windows, the binary file is located in C :\mysql\bin .

[root@host]# mysqladmin --version
Copy after login

This command on Linux will output the following results, which are based on your system information:

mysqladmin Ver  8.23  Distrib  5.0.9-0,  for redhat-linux-gnu on i386
Copy after login

If no information is output after the above command is executed, it means that your Mysql was not installed successfully.

After Mysql is installed successfully, the default root user password is empty. You can use the following command to create the root user's password:

[root@host]# mysqladmin -u root password "new_password";
Copy after login

Now you can connect to the Mysql server through the following command:

[root@host]# mysql -u root -p *******
Copy after login

Note: When entering the password, the password will not be displayed. Just enter it correctly.

Recommended study: "linux video tutorial"

The above is the detailed content of One article explains how to install MySQL with yum on Linux/UNIX. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template