Home  >  Article  >  Database  >  How to install MySQL under CentOS6

How to install MySQL under CentOS6

PHPz
PHPzOriginal
2023-04-19 15:21:00596browse

MySQL is a relational database management system that is widely used in various web application development. This article will introduce how to install MySQL on CentOS 6.

Preparations before installing MySQL

Before installing MySQL, you need to ensure that your system has installed the EPEL software warehouse. If you have not installed it, you can use the following command to install it.

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

In addition, you also need to install some other necessary software packages:

yum install wget zip unzip

Installation MySQL steps

  1. Add MySQL software repository
    Installation on CentOS 6 For MySQL, you first need to add the MySQL software repository to the system. We can find the corresponding software warehouse on the MySQL official website, then download and install it.
wget http://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm
yum localinstall mysql57-community-release-el6-9.noarch.rpm
  1. Install MySQL server
    The yum command can automatically install the MySQL server and its dependent packages, and can also enable the MySQL service.
yum install mysql-server
service mysqld start
  1. Modify the MySQL configuration file
    In order to ensure the security of the MySQL server, remote connections are prohibited under its default configuration. In order to remotely access the MySQL server, we need to modify the MySQL configuration file and change the bind-address to 0.0.0.0 so that the MySQL server can listen for connection requests from any IP address.
vim /etc/my.cnf

Add a line under the [mysqld] tag:

bind-address=0.0.0.0
  1. Create MySQL administrator
    After MySQL is installed, we need to create a password for MySQL.
mysql_secure_installation

This command will prompt you to enter the MySQL root password, and then prompt you whether to set a new password. Then it will remind you about some security settings of the server and give you some choices.

  1. Enable MySQL remote access
    Now we can access the MySQL server through the remote MySQL client, just enter the IP address and port number of the MySQL server in the client, as shown below:
mysql -h  -P <端口号> -u <用户名> -p

where and are the IP address and port number of the MySQL server, and are those of the MySQL administrator user name and password.

Summary

Through this article, we know the steps to install MySQL on CentOS 6. MySQL is an essential tool if you want to deploy web applications on CentOS. If you want, you can try installing MySQL and start developing a web application.

The above is the detailed content of How to install MySQL under CentOS6. 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