Table of Contents
1 Download and install MySQL official Yum Repository, Mysql version 5.7.14
4 、开启防火墙端口,CentOS为firewalld添加开放端口3306,具体是什么参考如下:
5 、更改mysql的语言
Home Database Mysql Tutorial How to install mysql under centos

How to install mysql under centos

Dec 02, 2021 am 11:16 AM
centos mysql

How to install mysql under centos: 1. Download and install the official MySQL Yum Repository; 2. Install the MySQL server; 3. Log in to the database; 4. Modify the MySQL default password; 5. Enable remote access to mysql. Can.

How to install mysql under centos

The operating environment of this article: Windows 7 system, Mysql version 5.7.14, Dell G3 computer.

How to install mysql under centos?

CentOS7 installation MySQL (full version)

MariaDB is installed by default in CentOS. This is a branch of MySQL, but for needs, it still needs to be installed in the system. Install MySQL in and overwrite MariaDB directly after the installation is complete.

1 Download and install MySQL official Yum Repository, Mysql version 5.7.14

[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
Copy after login
Copy after login

## Use the above command to directly download the Yum Repository for installation. , about 25KB, and then you can install it directly with yum.

[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
Copy after login
Copy after login

Then start installing the MySQL server

[root@localhost ~]# yum -y install mysql-community-server
Copy after login
This step may take some time. After the installation is completed, the previous mariadb will be overwritten. How long will it take? Depends on personal internet speed.

After the installation is complete, let’s do some configuration of mysql.

2 MySQL database settings

(1) First start MySQL

[root@localhost ~]# systemctl start  mysqld.service
Copy after login
(2) Check the running status of MySQL. The running status is as shown in the figure:

[root@localhost ~]# systemctl status mysqld.service
Copy after login

(3) MySQL has started to run normally at this time, but in order to enter MySQL, you must first find out the password of the root user at this time. You can find the password in the log file through the following command:

[root@localhost ~]# grep "password" /var/log/mysqld.log
Copy after login

(4) Log in to the database with the following command:

[root@localhost ~]# mysql -uroot -p
Copy after login
(5) You cannot do anything at this time, because MySQL must change the password by default before you can operate the database. Use the following command to change the password:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
Copy after login
Replace 'new password' with the password you want to set. Note: The password setting must contain uppercase and lowercase letters and numbers and special symbols (,/';:, etc.), otherwise it cannot be configured. success.

If the following error occurs:

It is thought that the password complexity does not meet the default requirements. Use the following command to view the mysql default password complexity:

SHOW VARIABLES LIKE 'validate_password%';
Copy after login

If you need to change the password complexity, please refer to the following command:

set global validate_password_policy=LOW;
Copy after login

set global validate_password_length=6;
Copy after login

##3 Open Mysql remote access

Execute the following command to enable remote access restrictions (note: the IP enabled by the following command is 192.168.19.128. If you want to enable all, use % instead of IP):

grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;
Copy after login

Note: password--is the password you set for your mysql remote login.

Then enter the following two lines of commands

mysql> flush privileges;
Copy after login
You can also exit mysql for this step. Specific reference:

4 、开启防火墙端口,CentOS为firewalld添加开放端口3306,具体是什么参考如下:

    https://i-beta.cnblogs.com/posts?cateId=1653053

5 、更改mysql的语言

首先重新登录mysql,然后输入status:

 可以看到,红色方框处不是utf-8,修改为utf8即可。

因此我们先退出mysql,然后再到/etc目录下的my.cnf文件下修改一下文件内容

cd /etc
Copy after login

 进入文件后,新增四行代码:

 保存更改后的my.cnf文件后,重启下mysql,然后输入status再次查看,你就会发现变化啦

 

 到此CentOS7安装Mysql5.7完毕。

set global validate_password_policy=LOW;

【相关推荐:mysql视频教程

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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1670
14
PHP Tutorial
1274
29
C# Tutorial
1256
24
MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Explain the purpose of foreign keys in MySQL. Explain the purpose of foreign keys in MySQL. Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

Compare and contrast MySQL and MariaDB. Compare and contrast MySQL and MariaDB. Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

CentOS: What Led to the Decision to End Support CentOS: What Led to the Decision to End Support Apr 23, 2025 am 12:10 AM

RedHatendedsupportforCentOStoshifttowardsacommerciallyfocusedmodelwithCentOSStream.1)CentOStransitionedtoCentOSStreamforRHELdevelopment.2)ThisencourageduserstomovetoRHEL.3)AlternativeslikeAlmaLinux,RockyLinux,andOracleLinuxemergedasreplacements.

SQL vs. MySQL: Clarifying the Relationship Between the Two SQL vs. MySQL: Clarifying the Relationship Between the Two Apr 24, 2025 am 12:02 AM

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

MySQL: The Database, phpMyAdmin: The Management Interface MySQL: The Database, phpMyAdmin: The Management Interface Apr 29, 2025 am 12:44 AM

MySQL and phpMyAdmin can be effectively managed through the following steps: 1. Create and delete database: Just click in phpMyAdmin to complete. 2. Manage tables: You can create tables, modify structures, and add indexes. 3. Data operation: Supports inserting, updating, deleting data and executing SQL queries. 4. Import and export data: Supports SQL, CSV, XML and other formats. 5. Optimization and monitoring: Use the OPTIMIZETABLE command to optimize tables and use query analyzers and monitoring tools to solve performance problems.

How to safely store JavaScript objects containing functions and regular expressions to a database and restore? How to safely store JavaScript objects containing functions and regular expressions to a database and restore? Apr 19, 2025 pm 11:09 PM

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

Steps to add and delete fields to MySQL tables Steps to add and delete fields to MySQL tables Apr 29, 2025 pm 04:15 PM

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

See all articles