Home  >  Article  >  Database  >  How to install mysql on centos6.5

How to install mysql on centos6.5

PHPz
PHPzOriginal
2023-04-20 10:06:41834browse

In server construction, database construction is an indispensable part. As the most widely used relational database management system at present, MySQL has excellent stability, security and scalability, so it is widely used in various website applications, data analysis, embedded systems and other fields. This article will introduce in detail how to install MySQL under CentOS6.5 system.

1. Install MySQL

1. Update the system

Before installing the software, we need to update our system first to ensure that the operating system is up to date. Use the following command to update the system:

yum -y update

2. Install MySQL

  • Install MySQL

Use the yum command to install MySQL with one click:

yum -y install mysql-server mysql
  • Configuring MySQL

After the MySQL installation is completed, we need to perform some basic configurations, such as starting the MySQL service, setting up auto-start, etc.

Use the following command to start the MySQL service:

service mysqld start

Use the following command to set auto-start at boot:

chkconfig mysqld on

3. Connect to MySQL

  • Log in to MySQL

After the MySQL installation is completed, we need to log in to MySQL to perform some basic configuration, such as creating databases, users, etc.

Use the following command to log in to MySQL:

mysql -u root -p
  • Change the root password

When MySQL is installed by default, the password of the root user is empty, we need to perform a Change of initial password. After logging in to MySQL, execute the following command:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');

4. Basic operations

  • Create database

Use the following command to create a new database:

CREATE DATABASE test;
  • Delete database

Delete an existing database:

DROP DATABASE test;
  • Create user

Use as follows Command to create a normal user:

GRANT ALL PRIVILEGES ON test.* TO 'username'@'localhost' IDENTIFIED BY 'password';

The test.* here indicates that the user has operating permissions for all tables under the test database.

  • Query user permissions

Use the following command to query the created user permissions:

SHOW GRANTS FOR 'username'@'localhost';
  • Delete user

Use the following command to delete a user:

DROP USER 'username'@'localhost';

2. Summary

The above are the detailed steps for installing MySQL under CentOS6.5. It should be noted that the root user should not be revealed during the installation process. password, and a complex password should be set to prevent attacks. After the installation is complete, MySQL should be properly configured and optimized to ensure its performance and security.

The above is the detailed content of How to install mysql on centos6.5. 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