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:
1 |
|
If your system has it installed, you can choose to uninstall it:
1 2 |
|
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.
1 2 3 4 |
|
Permission settings:
1 |
|
Initialize MySQL:
1 |
|
Start MySQL:
1 |
|
View MySQL running status:
1 |
|
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.
1 |
|
The relevant commands for the mariadb database are:
1 2 3 4 |
|
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 .
1 |
|
This command on Linux will output the following results, which are based on your system information:
1 |
|
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:
1 |
|
Now you can connect to the Mysql server through the following command:
1 |
|
Note: When entering the password, the password will not be displayed. Just enter it correctly.