Home > Database > Mysql Tutorial > How to install MySQL on CentOS 6.5

How to install MySQL on CentOS 6.5

PHPz
Release: 2023-04-21 13:57:35
Original
619 people have browsed it

CentOS 6.5 is a very popular Linux operating system. MySQL is a world-famous relational database. It is very easy to install MySQL on CentOS 6.5. This article will introduce you in detail how to install MySQL on CentOS 6.5.

  1. Preparation before installing MySQL

Before installing MySQL, you need to confirm whether the MariaDB database has been installed on the CentOS 6.5 system. If it has been installed, you need to uninstall MariaDB. You can use the following command to check whether MariaDB has been installed:

rpm -qa | grep MariaDB

If there is no output, it means MariaDB is not installed. If MariaDB has been installed, use the following command to uninstall:

yum remove mariadb-libs

After the uninstallation is complete, you can use the following command to check whether the uninstallation was successful:

rpm - qa | grep MariaDB

If there is no output result, it means MariaDB has been successfully uninstalled.

  1. Install MySQL

Installing MySQL on CentOS 6.5 is very simple, you can use the following command to install:

yum install mysql-server

After executing the command, the system will automatically download the MySQL installation package and install it. After the installation is complete, start the MySQL service:

service mysqld start

Check the MySQL service status:

service mysqld status

If the MySQL service has been started, then The following information will be output:

mysqld (pid xxxxx) is running...

  1. Configuring MySQL

After the installation is completed, MySQL needs to be configured , including setting the root user password, adding permission for remote access, etc.

3.1 Set the root user password

Enter the following command to set the root user password:

mysqladmin -u root password 'new-password'

Among them, new-password is the new password.

3.2 Adding permission for remote access

By default, MySQL only allows local access. If you need to allow access from other machines, you need to perform the following configuration.

First, enter the MySQL configuration file my.cnf:

vi /etc/my.cnf

Add the following content:

[mysqld]
bind-address = 0.0.0.0

Save and exit.

Next, restart the MySQL service:

service mysqld restart

3.3 Other configurations

You can also perform some other configurations, such as setting the default character set wait. You can use the following command to view all current MySQL configuration information:

mysql -u root -p -e "show variables like '%character_set%';"

  1. Test MySQL

After the installation and configuration are completed, you can test whether MySQL is working properly. You can use the following command to log in to MySQL:

mysql -u root -p

After entering the password, if the login is successful, MySQL is working normally.

You can use the following command to view the current MySQL version information:

mysql> select version();

If the version number is output, it means that MySQL has been installed successfully and is working normally. .

  1. Summary

This article introduces the steps to install MySQL on CentOS 6.5, including preparation, installation, configuration and testing. I hope it will be helpful to everyone.

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