Table of Contents
1. Check whether the mysql service or development package dependencies have been installed in the system
2. Check the installation packages that can be used on the yum source (if there are requirements for the mysql version, you can modify the configuration of the yum source)
3. Install mysql-server and use the yum install command. During the installation process, all dependent packages will be automatically downloaded and installed
4. Start the mysqld service
5. Use the mysql database
Home Database Mysql Tutorial Teach you how to install Mysql online

Teach you how to install Mysql online

Sep 16, 2021 pm 03:53 PM
mysql

1. Check whether the mysql service or development package dependencies have been installed in the system

[bigdata@bigdata-pro02 ~]$ rpm -qa | grep mysql
mysql-libs-5.1.73-3.el6_5.x86_64
Copy after login

If there are some installation packages, check , then use rpm -e --nodeps [Installation Package 1] [Installation Package 2] [...] to uninstall the existing installation package.
You need to switch to the root user here

[root@bigdata-pro02 ~]# rpm -e --nodeps mysql-libs-5.1.73-3.el6_5.x86_64
[root@bigdata-pro02 ~]#
Copy after login

2. Check the installation packages that can be used on the yum source (if there are requirements for the mysql version, you can modify the configuration of the yum source)

Use yum list | grep mysql to check the available installation packages

[root@bigdata-pro02 ~]# yum list | grep mysql-server
mysql-server.x86_64                            5.1.73-8.el6_8               @base
Copy after login

3. Install mysql-server and use the yum install command. During the installation process, all dependent packages will be automatically downloaded and installed

[root@bigdata-pro02 ~]# yum install mysql-server.x86_64 -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink                                                                                | 4.9 kB     00:00     
 * base: mirrors.163.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.163.com
base                                                                                         | 3.7 kB     00:00     
epel                                                                                         | 3.2 kB     00:00     
epel/primary                                                                                 | 3.2 MB     00:01     
epel                                                                                                    12521/12521
extras                                                                                       | 3.4 kB     00:00     
updates                                                                                      | 3.4 kB     00:00     
updates/primary_db                                                                           | 1.2 MB     00:00     
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.73-8.el6_8 will be installed
--> Processing Dependency: mysql = 5.1.73-8.el6_8 for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-8.el6_8 will be installed
---> Package mysql-libs.x86_64 0:5.1.73-8.el6_8 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================
 Package                        Arch                   Version                           Repository            Size
====================================================================================================================
Installing:
 mysql-server                   x86_64                 5.1.73-8.el6_8                    base                 8.6 M
Installing for dependencies:
 mysql                          x86_64                 5.1.73-8.el6_8                    base                 895 k
 mysql-libs                     x86_64                 5.1.73-8.el6_8                    base                 1.2 M
 perl-DBD-MySQL                 x86_64                 4.013-3.el6                       base                 134 k
 perl-DBI                       x86_64                 1.609-4.el6                       base                 705 k

Transaction Summary
====================================================================================================================
Install       5 Package(s)

Total download size: 12 M
Installed size: 33 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): mysql-5.1.73-8.el6_8.x86_64.rpm                                                       | 895 kB     00:00     
(2/5): mysql-libs-5.1.73-8.el6_8.x86_64.rpm                                                  | 1.2 MB     00:00     
(3/5): mysql-server-5.1.73-8.el6_8.x86_64.rpm                                                | 8.6 MB     00:03     
(4/5): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                                 | 134 kB     00:00     
(5/5): perl-DBI-1.609-4.el6.x86_64.rpm                                                       | 705 kB     00:00     
--------------------------------------------------------------------------------------------------------------------
Total                                                                               2.4 MB/s |  12 MB     00:04     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of libmysqlclient.so.16()(64bit)
2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of mysql-libs
  Installing : mysql-libs-5.1.73-8.el6_8.x86_64                                                                 1/5 
  Installing : perl-DBI-1.609-4.el6.x86_64                                                                      2/5 
  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                3/5 
  Installing : mysql-5.1.73-8.el6_8.x86_64                                                                      4/5 
  Installing : mysql-server-5.1.73-8.el6_8.x86_64                                                               5/5 
  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                1/5 
  Verifying  : mysql-libs-5.1.73-8.el6_8.x86_64                                                                 2/5 
  Verifying  : mysql-server-5.1.73-8.el6_8.x86_64                                                               3/5 
  Verifying  : mysql-5.1.73-8.el6_8.x86_64                                                                      4/5 
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                                                      5/5 

Installed:
  mysql-server.x86_64 0:5.1.73-8.el6_8                                                                              

Dependency Installed:
  mysql.x86_64 0:5.1.73-8.el6_8     mysql-libs.x86_64 0:5.1.73-8.el6_8     perl-DBD-MySQL.x86_64 0:4.013-3.el6    
  perl-DBI.x86_64 0:1.609-4.el6    

Complete!
Copy after login

Check whether mysql is installed in the system

[root@bigdata-pro02 ~]# rpm -qa | grep mysql
mysql-5.1.73-8.el6_8.x86_64
mysql-libs-5.1.73-8.el6_8.x86_64
mysql-server-5.1.73-8.el6_8.x86_64
Copy after login

Check the location of the mysql command

[root@bigdata-pro02 ~]# which mysql
/usr/bin/mysql
Copy after login

4. Start the mysqld service

[root@bigdata-pro02 ~]# service mysqld status
mysqld is stopped
[root@bigdata-pro02 ~]# service mysqld start
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h bigdata-pro02.mars.com password 'new-password'
**# 以上为两种新建root用户并设置密码的方式**

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
Copy after login

5. Use the mysql database

Add root user and set password

[root@bigdata-pro02 ~]# /usr/bin/mysqladmin -u root password '123456'
Copy after login

Log in to mysql database

[root@bigdata-pro02 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

mysql> use test;
Database changed
mysql> show tables;
Empty set (0.01 sec)

mysql> create table test1 (id int(10), name varchar(20) ) ;
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| test1          |
+----------------+
1 row in set (0.00 sec)
Copy after login

Recommended learning: "mysql video tutorial"

The above is the detailed content of Teach you how to install Mysql online. 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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 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)

PHP's big data structure processing skills PHP's big data structure processing skills May 08, 2024 am 10:24 AM

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values ​​to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

The difference between oracle database and mysql The difference between oracle database and mysql May 10, 2024 am 01:54 AM

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.

See all articles