Home > Database > Mysql Tutorial > How to install mysql on centos 6

How to install mysql on centos 6

PHPz
Release: 2023-04-21 13:58:17
Original
1206 people have browsed it

CentOS 6 is a free and open source operating system that supports a wide range of applications and software. Among them, MySQL is a popular relational database management system that can be used to store and manage large amounts of data. In this article, we will explain how to install MySQL on CentOS 6.

Step 1: Update the system

Before starting the installation of MySQL, we should update the system first to ensure that we have the latest security patches and software packages.

Open a terminal and run the following command as the root user:

yum update

Step 2: Install MySQL

Now, we can start the installation of MySQL . We will use yum to perform the installation process.

Run the following command as the root user:

yum install mysql-server

This command will install MySQL and its related files and dependencies. During the installation process, you may need to press "y" to confirm the installation.

Step 3: Start MySQL

Now that MySQL is installed, we need to start it. Use the following command to start the MySQL service:

service mysqld start

If all goes well, you should see the "Starting mysqld: [Successful]" message.

Step 4: Set up MySQL

Once the MySQL service has been started, we need to set it up by entering the following command:

/usr/bin/mysql_secure_installation

This command will prompt you to set the password of the MySQL root user and allow you to choose whether to remove the test database and delete anonymous users. We recommend that you follow these best practices so you can better protect the security and performance of MYSQL.

Step 5: Test MySQL

Now that MySQL is installed and set up, we can test whether it works properly.

Use the following command to log in to MySQL:

mysql -u root -p

Then enter the MySQL root user password you set.

If everything is fine, you should see the MySQL command prompt.

At this point, you can run various commands to test the functionality and performance of MySQL, such as "SHOW DATABASES" to list all available databases.

Step 6: Configure MySQL

On CentOS 6, the main configuration file for MySQL is located in /etc/my.cnf. You can customize MySQL settings such as cache size, logging, and more by editing this file. However, if you are not a professional, it is best not to change the default settings.

Finally, to ensure that MySQL can run properly, make sure that the firewall allows access to it from the external network.

Execute the following command to open the MySQL port:

iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

Execute the following command to update and save iptables:

/etc/init.d/iptables save

At this point, you have successfully installed MySQL on CentOS 6. MySQL is a very powerful and flexible database management system suitable for use in a variety of corporate and personal projects. With the introduction in this article, you can now use MySQL to store and manage large amounts of data.

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

source:php.cn
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