centos mysql settings

WBOY
Release: 2023-05-20 09:45:37
Original
782 people have browsed it

CentOS MySQL Settings

MySQL is an open source relational database management system. It is one of the most popular databases and is widely used in the development and management of web applications and Internet websites. This article will introduce how to set up and configure MySQL on the CentOS operating system.

  1. Install MySQL

Installing MySQL in CentOS is very simple, you can use the following command to install it in your system:

sudo yum install mysql- server

This command will install the MySQL server and related dependencies.

  1. Start the MySQL service

After the installation is complete, you need to start the MySQL service. You can use the following command to start the MySQL service:

sudo service mysqld start

You can also use the following command to start the MySQL service:

sudo systemctl start mysqld

This command will start the MySQL service and run it in the background.

  1. Configuring MySQL

By default, the CentOS MySQL server does not have a password. For increased security, you need to set a root user password for MySQL.

You can set the MySQL root user password using the following command:

sudo mysql_secure_installation

After running this command, you will be prompted for the root password. Enter the password you want to use and press Enter to continue.

The script will then provide you with some options to modify MySQL security settings. If you wish to enforce password policy and remove anonymous users, enter y.

Next, you need to enter the new password for this root user. You will be asked to confirm your passwords to make sure they match.

Finally, you have the option to delete the test database and the users accessing the test database, which is a common vulnerability with improperly configured MySQL databases.

  1. Log in to MySQL

After completing the installation and configuration of MySQL, you can use the following command to log in to MySQL:

mysql -u root -p

This command will prompt you to enter the root password you just created. After entering your password, press Enter to continue. If you entered the password correctly, you will see a MySQL prompt. This means you can now interact with MySQL and perform various operations you want.

  1. Firewall Settings

In order to access the MySQL server on a remote computer, you need to open the MySQL server's port to allow connections.

You can configure the firewall in CentOS 7 to allow inbound traffic to the MySQL port (default is 3306) by using the following command:

sudo firewall-cmd --zone=public -- add-port=3306/tcp --permanent
sudo firewall-cmd --reload

This will add an entry in the firewall rules to allow the MySQL port so that other computers can connect to your MySQL server.

If you are using an older version of CentOS, such as CentOS 6, you can use the following command:

sudo iptables -A INPUT -m state --state NEW -m tcp -p tcp - -dport 3306 -j ACCEPT
sudo service iptables save

This will ensure that the iptables rule that allows the MySQL port is set and saves it so that it is retained until the next reboot.

Summary

MySQL is a powerful relational database management system that is widely used in Web application and Internet website development and management. By following the above steps, you can easily set up and configure MySQL in CentOS. Additionally, you can increase the security of your MySQL server to ensure that it is not vulnerable to attacks and provides more reliable services.

The above is the detailed content of centos mysql settings. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!