Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install MySQL5.5 in Linux

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to install MySQL5.5 in Linux, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

1.1 description of the MySQL installation file type on the official documentation:

Linux supports anumber of different solutions for installing MySQL. The recommended method isto use one of the distributions from Oracle. If you choose this method, thereare three options available:

(1) Installingfrom a generic binary package in .tar.gz format. See for moreinformation.

(2) Extractingand compiling MySQL from a source distribution. For detailed instructions,see.

(3) Installingusing a pre-compiled RPM package. For more information on using the RPMsolution, see.

Here are three ways to install the MySQL database, and I use the simplest RPM package to install it.

As analternative, you can use the native package manager within your Linuxdistribution to automatically download and install MySQL for you. Nativepackage installations can take of the download and dependencies required to runMySQL, but the MySQL version will often be some way behind the currentlyavailable release. You will also normally be unable to install developmentalreleases, as these are not usually made available in the native repository. Formore information on using the native package installers, see.

Note

For many Linux installations,you will want to set up MySQL to be started automatically when your machinestarts. Many of the native package installations perform this operation foryou, but for source, binary and RPM solutions you may need to set this upseparately. The required script, can be found in the support-filesdirectory under the MySQL installationdirectory or in a MySQL source tree. You can install itas/etc/init.d/mysql for automatic MySQL startup and shutdown. See.

-- one problem to pay attention to here is to set the self-startup of MySQL. If you use native package to install, it will be automatically set to self-boot, and if you use other methods, such as source,binary and RPM, you will need to set up self-startup separately.

1.2 download installation package

I download the Community Server version here, and the Enterprise Edition version can be downloaded from Oracle E-Delivery. Enterprise Edition has a 30-day probation period.

Download address of Community Server:

It should be noted here that the Tar package of MySQL is still relatively large, about 3 times larger than the RPM package.

There are several RPM packages for MySQL:

Take a look at the specific description of each rpm package:

(1) MySQL-server-VERSION.glibc23.i386.rpm

The MySQLserver. You need this unless you only want to connect to a MySQL server runningon another machine.

(2) MySQL-client-VERSION.glibc23.i386.rpm

The standardMySQL client programs. You probably always want to install this package.

(3) MySQL-devel-VERSION.glibc23.i386.rpm

The librariesand include files that are needed if you want to compile other MySQL clients,such as the Perl modules.

(4) MySQL-debuginfo-VERSION.glibc23.i386.rpm

This packagecontains debugging information. Debuginfo RPMs are never needed touse MySQL software; this is true both for the server and for client programs.However, they contain additional information that might be needed by a debuggerto analyze a crash.

(5) MySQL-shared-VERSION.glibc23.i386.rpm

This packagecontains the shared libraries (libmysqlclient.so*) that certain languages andapplications need to dynamically load and use MySQL. It containssingle-threaded and thread-safe libraries. Prior toMySQL 5.5.6, if you install this package, do not installthe MySQL-shared-compat package.

(6) MySQL-shared-compat-VERSION.glibc23.i386.rpm

This packageincludes the shared libraries for MySQL 3.23, 4.0, and so on. It containssingle-threaded and thread-safe libraries. Install this package if you have applicationsinstalled that are dynamically linked against older versions of MySQL but youwant to upgrade to the current version without breaking the librarydependencies. Before MySQL 5.5.6, MySQL-shared-compat also includesthe libraries for the current release, so if you install it, you should notalso install MySQL-shared. As of 5.5.6, MySQL-shared-compat doesnot include the current library version, so there is no conflict.

(7) MySQL-embedded-VERSION.glibc23.i386.rpm

The embeddedMySQL server library.

(8) MySQL-test-VERSION.glibc23.i386.rpm

This packageincludes the MySQL test suite.

(9) MySQL-VERSION.src.rpm

This containsthe source code for all of the previous packages. It can also be used torebuild the RPMs on other architectures (for example, Alpha or SPARC).

two。 Install MySQL2.1 installation instructions

(1) there are many installation packages for MySQL, and their functions are also different. in most cases, only MySQL-server and MySQL-client need to be installed, and other packages are installed as needed.

(2) The server RPM places data underthe / var/lib/mysql directory. The RPM also creates a login accountfor a user named mysql (if one does not exist) to use for running theMySQL server, and creates the appropriate entries in / etc/init.d/ tostart the server automatically at boot time. (This means that if you haveperformed a previous installation and have made changes to its startup script,you may want to make a copy of the script so that you do not lose it when youinstall a newer RPM.)

(3) During RPM installation, a usernamed mysql and a group named mysql are created on thesystem. This is done using the useradd, groupadd,and usermod commands. Those commands require appropriateadministrative privileges, which is required for locally managed users andgroups (as listed in the / etc/passwd and / etc/groupfiles) by theRPM installation process being run by root.

-- during MySQL installation, mysql users and mysql groups are created.

(4) description of relevant catalogs of MySQL

/ usr/bin: Client programs and scripts-- mysqladmin mysqldump and other commands

/ usr/sbin: The server

/ var/lib/mysql: Log files, databases-- this is the directory of the database

/ usr/share/info: Manual in Info format

/ usr/share/man: Unix manual pages

/ usr/include/mysql: Include (header) files

/ usr/lib/mysql: Libraries

/ usr/share/mysql: Miscellaneous support files,including error messages, character set files, sample configuration files, SQLfor database installation

-- mysql.server commands and configuration files

/ usr/share/sql-bench: Benchmarks

Directory of / etc/rc.d/init.d/: startup script file mysql

2.2 installation

-- install the server:

[root@rac2 software] # ls

MySQL-client-5.5.15-1.rhel5.x86_64.rpm

MySQL-devel-5.5.15-1.rhel5.x86_64.rpm

MySQL-embedded-5.5.15-1.rhel5.x86_64.rpm

MySQL-server-5.5.15-1.rhel5.x86_64.rpm

MySQL-shared-5.5.15-1.rhel5.x86_64.rpm

MySQL-shared-compat-5.5.15-1.rhel5.x86_64.rpm

MySQL-test-5.5.15-1.rhel5.x86_64.rpm

[root@rac2 software] # rpm-ivh MySQL-server-5.5.15-1.rhel5.x86_64.rpm

Preparing... # [100%]

1:MySQL-server # # [100%]

PLEASE REMEMBER TO SET A PASSWORD FOR THEMySQL root USER!

To do so, start the server, then issue thefollowing commands:

/ usr/bin/mysqladmin-u root password'new-password'

/ usr/bin/mysqladmin-u root-h rac2password 'new-password'

Alternatively you can run:

/ usr/bin/mysql_secure_installation

Which will also give you the option ofremoving the test

Databases and anonymous user created bydefault. This is

Strongly recommended for productionservers.

See the manual for more instructions.

Please report any problems with the / usr/bin/mysqlbugscript!

[root@rac2 software] #

-install the client

[root@rac2 software] # rpm-ivh MySQL-client-5.5.15-1.rhel5.x86_64.rpm

Preparing... # [100%]

1:MySQL-client # # [100%]

2.3 other actions

2.3.1 View the mysql user and mysql group created at the time:

[root@rac2 bin] # cat / etc/passwd | grep mysql

Mysql:x:103:106:MySQLserver:/var/lib/mysql:/bin/bash

[root@rac2 bin] # cat / etc/group | grepmysql

Mysql:x:106:

2.3.2 change password

-- an error was reported when connecting to MySQL:

[root@rac2 software] # mysql

ERROR 2002 (HY000): Can't connect to localMySQL server through socket'/ var/lib/mysql/mysql.sock' (2)

-- after starting MySQL, the connection is normal:

[root@rac2 ~] # / etc/init.d/mysql start

Starting MySQL... [OK]

[root@rac2 init.d] # mysql

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 1

Server version: 5.5.15 MySQL CommunityServer (GPL)

Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its

Affiliates. Other names may be trademarksof their respective

Owners.

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

Mysql >

Note here, because MySQL does not have a password by default, we connect directly here without entering a password.

-- change the password, which is prompted in the installation of Server:

[root@rac2] # / usr/bin/mysqladmin-u root password root

[root@rac2 ~] # mysql

ERROR 1045 (28000): Access denied for user'root'@'localhost' (using password: NO)

After changing the password, you are prompted to use the password.

[root@rac2] # mysql-u root-p

Enter password:

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 5

Server version: 5.5.15 MySQL CommunityServer (GPL)

Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its affiliates. Other names may be trademarks of theirrespective owners.

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

Mysql >

-- successfully connect after entering the password.

2.3.3 check MySQL port 3306, which is the default port:

[root@rac2 ~] # netstat-nat | grep 3306

Tcp 00 192.168.3.100:32842 192.168.3.100:3306 TIME_WAIT

Tcp 0 0: 3306: * LISTEN

2.3.4 set boot self-startup

-- View MySQL boot settings:

[root@rac2 ~] # chkconfig-- list | grep mysql

Mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

The numbers here represent the different modes of startup, 3 is the command line and 5 is the window.

-- turn off boot self-startup

[root@rac2 ~] # chkconfig mysql off

[root@rac2 ~] # chkconfig-- list | grep mysql

Mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off

-- enable boot self-startup:

[root@rac2 ~] # chkconfig mysql on

[root@rac2 ~] # chkconfig-- list | grep mysql

Mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@rac2 ~] #

-- remove Mysql from the chkconfig service:

[root@rac2] # chkconfig-- del mysql

[root@rac2 ~] # chkconfig-- list | grep mysql

-- add Mysql to chkconfig:

[root@rac2] # chkconfig-- add mysql

[root@rac2 ~] # chkconfig-- list | grep mysql

Mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

2.4 Operation

[root@rac2] #-u root-p

Enter password:

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 6

Server version: 5.5.15 MySQL CommunityServer (GPL)

Copyright (c) 2000, 2010, and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its

Affiliates. Other names may be trademarksof their respective

Owners.

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

-- View existing databases, which are automatically created during installation

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

| | test |

+-+

4 rows in set (0.00 sec)

-- using the mysql database

Mysql > use mysql

Reading table information for completion oftable and column names

You can turn off this feature to get aquicker startup with-A

Database changed

-- View the tables under the mysql database

Mysql > show tables

+-+

| | Tables_in_mysql |

+-+

| | columns_priv |

| | db |

| | event |

| | func |

| | general_log |

| | help_category |

| | help_keyword |

| | help_relation |

| | help_topic |

| | host |

| | ndb_binlog_index |

| | plugin |

| | proc |

| | procs_priv |

| | proxies_priv |

| | servers |

| | slow_log |

| | tables_priv |

| | time_zone |

| | time_zone_leap_second |

| | time_zone_name |

| | time_zone_transition |

| | time_zone_transition_type |

| | user |

+-+

24 rows in set (0.01 sec)

-- create a database Dave

Mysql > create database dave

Query OK, 1 row affected (0.01sec)

-- create the dave table under the dave database:

Mysql > use dave

Database changed

Mysql > create table dave (id int,namechar (20))

Query OK, 0 rows affected (0.01 sec)

-- View the dave table structure:

Mysql > desc dave

+-+ +

| | Field | Type | Null | Key | Default | Extra | |

+-+ +

| | id | int (11) | YES | | NULL |

| | name | char (20) | YES | | NULL |

+-+ +

2 rows in set (0.00 sec)

-insert 2 records into the dave table:

Mysql > insert into davevalues (1)

Query OK, 1 row affected (0.00 sec)

Mysql > insert into davevalues (2)

Query OK, 1 row affected (0.01sec)

Mysql > select * from dave

+-+ +

| | id | name |

+-+ +

| | 1 | dave |

| | 2 | anqing |

+-+ +

2 rows in set (0.00 sec)

-- update table:

Mysql > update dave set name='david dai'where id=1

Query OK, 1 row affected (0.01sec)

Rows matched: 1 Changed: 1 Warnings: 0

Mysql > select * from dave

+-+ +

| | id | name |

+-+ +

| | 1 | david dai |

| | 2 | anqing |

+-+ +

2 rows in set (0.00 sec)

-- drop table:

Mysql > drop table dave

Query OK, 0 rows affected (0.01 sec)

-drop database:

Mysql > drop database dave

Query OK, 0 rows affected (0.00 sec)

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

| | test |

+-+

4 rows in set (0.01sec)

On how to install MySQL5.5 in Linux to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report