Home > Database > Mysql Tutorial > How to install mysql on centos6.5

How to install mysql on centos6.5

PHPz
Release: 2023-04-20 10:42:13
Original
866 people have browsed it

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
Copy after login

2. Install MySQL

  • Install MySQL

Use the yum command to install MySQL with one click:

yum -y install mysql-server mysql
Copy after login
  • 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
Copy after login

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

chkconfig mysqld on
Copy after login

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
Copy after login
  • 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');
Copy after login

4. Basic operations

  • Create database

Use the following command to create a new database:

CREATE DATABASE test;
Copy after login
  • Delete database

Delete an existing database:

DROP DATABASE test;
Copy after login
  • Create user

Use as follows Command to create a normal user:

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

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';
Copy after login
  • Delete user

Use the following command to delete a user:

DROP USER 'username'@'localhost';
Copy after login

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!

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