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

What are the complete steps for CentOS to install MySQL5.5

2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you about the complete steps of installing MySQL5.5 in CentOS. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.

First, prepare before installation, download the installation package 1 and prepare for installation

Since CentOS7 comes with Mariadb, let's delete him first.

Find version

# rpm-qa | grep mariadb

After executing the command, there will be ghosts like MariaDB-server-5.5.49-1.el7.centos.x86_64. Just remember the name.

Delete

# rpm-e-- the file name found on nodeps

Delete Profil

# rm / etc/my.cnf

This is the OK. Now let's start installing mysql

2 download the installation package

Download address https://downloads.mysql.com/archives/community/

Start installation 1 upload the tar installation package to CentOS and decompress it

Upload

[root@bogon /] # cd / tmp [root@bogon tmp] # rz # then select the installation package to upload to CentOS [root @ bogon tmp] # ll-rw-r--r--. 1 root root 198993245 November 6 12:35 mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz

Decompression

[root@bogon tmp] # tar-zxvf mysql-5.5.62-linux-glibc2.12-x86_ 64.tar.gz [root @ bogon tmp] # lldrwxr-xr-x. 13 root root 213 November 6 12:41 mysql-5.5.62-linux-glibc2.12-x86_64-rw-r--r--. 1 root root 198993245 November 6 12:35 mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz2 moved to / usr/local directory and renamed [root@bogon tmp] # mv mysql-5.5.62-linux-glibc2.12-x86_64 / usr/local/ [root@bogon tmp] # cd / usr/local/ [root@bogon local] # ll Total usage 0drwxr-xr-x. 2 root root June May 11 2019 bindrwxr-xr-x. 2 root root June May 11 2019 etcdrwxr-xr-x. 2 root root June May 11 2019 gamesdrwxr-xr-x. 2 root root June May 11 2019 includedrwxr-xr-x. 2 root root June May 11 2019 libdrwxr-xr-x. 2 root root June May 11 2019 lib64drwxr-xr-x. 2 root root June May 11 2019 libexecdrwxr-xr-x. 13 root root 213 November 6 12:41 mysql-5.5.62-linux-glibc2.12-x86_64drwxr-xr-x. 2 root root June May 11 2019 sbindrwxr-xr-x. 5 root root 49 August 23 10:42 sharedrwxr-xr-x. 2 root root June May 11 2019 src [root@bogon local] # mv mysql-5.5.62-linux-glibc2.12-x86_64 mysql-5.5.60 [root@bogon local] # ll total dosage 0drwxr-xr-x. 2 root root June May 11 2019 bindrwxr-xr-x. 2 root root June May 11 2019 etcdrwxr-xr-x. 2 root root June May 11 2019 gamesdrwxr-xr-x. 2 root root June May 11 2019 includedrwxr-xr-x. 2 root root June May 11 2019 libdrwxr-xr-x. 2 root root June May 11 2019 lib64drwxr-xr-x. 2 root root June May 11 2019 libexecdrwxr-xr-x. 13 root root 213 November 6 12:41 mysql-5.5.60drwxr-xr-x. 2 root root June May 11 2019 sbindrwxr-xr-x. 5 root root 49 August 23 10:42 sharedrwxr-xr-x. 2 root root June May 11 2019 src3 add MySQL configuration file [root@bogon local] # vi / etc/my.cnf

Copy the following to the new file

[mysql] # set mysql client default character set default-character-set=utf8 socket=/var/lib/mysql/ mysql.sock [mysqld] skip-name-resolve# setting 3306 port port = 3306 socket=/var/lib/mysql/mysql.sock# set mysql installation directory, the directory here must be the directory where you unzipped and changed the name yo.. basedir=/usr/local/mysql-5.5.60# sets the directory where the data of the mysql database is stored The directory here must be the directory you unzipped and renamed. Datadir=/usr/local/mysql-5.5.60/data# allows maximum number of connections the character set used by the max_connections=200# server defaults to the 8-bit encoded latin1 character set character-set-server=utf8# will use when creating new tables the default storage engine default-storage-engine=INNODBlower_case_table_name=1max_allowed_packet=16M4 will be reconfigured and installed

Configuration commands:

# cd / usr/local/mysql-5.5.60# groupadd mysql# useradd-g mysql mysql# chown-R mysql:mysql. /

Installation commands:

. / scripts/mysql_install_db-- user=mysql-- basedir=/usr/local/mysql-5.5.60/-- datadir=/usr/local/mysql-5.5.60/data/

Demo:

[root@bogon local] # cd mysql-5.5.60/ [root@bogon mysql-5.5.60] # [root@bogon mysql-5.5.60] # groupadd mysqlgroupadd: "mysql" group already exists [root@bogon mysql-5.5.60] # useradd-g mysql mysqluseradd: user "mysql" already exists [root@bogon mysql-5.5.60] # chown-R mysql:mysql. / [root@bogon mysql-5.5.60] #. / scripts/mysql _ install_db-user=mysql-basedir=/usr/local/mysql-5.5.60/-datadir=/usr/local/mysql-5.5.60/data/Installing MySQL system tables.Please report any problems at http://bugs.mysql.com/[root@bogon mysql-5.5.60] # chown-R mysql:mysql data [root@bogon mysql-5.5.60] # chown 777 / etc/my.cnf [root@bogon mysql-5 .5.60] # Total amount of ll 56drwxr-xr-x. 2 mysql mysql 4096 November 6 12:41 bin-rw-r--r--. 1 mysql mysql 17987 August 29 2018 COPYINGdrwxr-xr-x. 5 mysql mysql 57 November 6 12:48 datadrwxr-xr-x. 2 mysql mysql 55 November 6 12:41 docsdrwxr-xr-x. 3 mysql mysql 4096 November 6 12:41 include-rw-r--r--. 1 mysql mysql 301 August 29 2018 INSTALL-BINARYdrwxr-xr-x. 3 mysql mysql 4096 November 6 12:41 libdrwxr-xr-x. 4 mysql mysql 30 November 6 12:41 mandrwxr-xr-x. 10 mysql mysql 4096 November 6 12:41 mysql-test-rw-r--r--. 1 mysql mysql 2496 August 29 2018 READMEdrwxr-xr-x. 2 mysql mysql 30 November 6 12:41 scriptsdrwxr-xr-x. 27 mysql mysql 4096 November 6 12:41 sharedrwxr-xr-x. 4 mysql mysql 4096 November 6 12:41 sql-benchdrwxr-xr-x. 2 mysql mysql 4096 November 6 12:41 support-files [root@bogon mysql-5.5.60] # cp. / support-files/mysql.server / etc/rc.d/init.d/mysqld [root@bogon mysql-5.5.60] # chmod + x / etc/rc.d/init.d/mysqld [root@bogon mysql-5.5.60] # chkconfig-- add mysqld [root@bogon mysql-5.5.60] # chkconfig-- list mysqld Note: the output only shows SysV services Does not include native systemd services. SysV configuration data may be overwritten by native systemd configurations. To list systemd services, execute 'systemctl list-unit-files'. To view the services enabled in a specific target, please execute 'systemctl list-dependencies [target]'. Mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off three, configure and start Service 1 configuration commands (in the MySQL directory) # chown-R mysql:mysql data# chown 777 / etc.my.cnf# cp. / support-files/mysql.server / etc/rc.d/init.d/mysqld# chmod + x / etc/rc.d/init.d/mysqld# chkconfig-- add mysqld# chkconfig-- list mysqld

The difference between chmod and chown

Chown modifies the user and user group properties of files and folders (1) modify the owner of the file hh.c. The user modified to sakia has all chown sakia hh.c # so that the user access rights of hh.c are applied to sakia as the owner (2) change the owner and group of the directory / tmp/sco to sakia and group net chown-R sakia:net / tmp/sco chmod modify files and folders read and write Implementation attributes (1) modify hh.c files to writable, readable and executable chmod 777 hh.c (2) to modify all file attributes in a directory to writeable, readable and executable chmod 777 *. * # replace the folder name and suffix name with *. (3) similarly, if you want to modify the properties of all htm files chmod 777 * .htm (4) change the directory / tmp/sco to writable, readable and executable chmod 777 / tmp/sco (5) change all folder properties under a directory to writable, readable and executable chmod 777 * # put the folder name Replace it with * (6) to modify all files and folders and their subfolder properties under / tmp/sco to writable, readable, executable chmod-R 777 / tmp/sco # # writable White4 readable Red2 executable xaccessible 1 777 The # # 2 startup service life [root@bogon mysql-5.5.60] # service mysqld start3 * of users and groups can be combined freely as needed and its solution

If you make a mistake,

[root@bogon mysql-5.5.60] # service mysqld startStarting MySQL.Logging to'/ usr/local/mysql-5.5.60/data/bogon.err'.201106 12:50:02 mysqld_safe Directory'/ var/lib/mysql' for UNIX socket file don't exists.ERROR! The server quit without updating PID file (/ usr/local/mysql-5.5.60/data/bogon.pid).

Solution method

Immediately execute the command: cat / usr/local/mysql/data/iZ2ze8hspx8qsmxx7b1i9sZ.err to check the cause of the error error content is as follows: [ERROR] Can't start server: Bind on unix socket: Permission denied [ERROR] Do you already have another mysqld server running on socket: / var/lib/mysql/mysql.sock? Combined with previously written configuration / etc/my.cnf:

It is not difficult to understand from above--

First:

Mysqld_safe Directory'/ var/lib/mysql' for UNIX socket file don't exists.

The "var/lib/mysql" directory does not exist. Create it first:

Mkdir / var/lib/mysql

Second:

The Mysql client and server communicate by initializing the mysql.sock file, so the server needs to write to the file when it starts, so the directory where the file is stored must be shared by both sides.

Have access rights. The exception log indicates:

[ERROR] Can't start server: Bind on unix socket: Permission denied

Therefore, the MySQL service does not have write access to the directory / var/lib/mysql and cannot generate a mysql.sock file, which cannot be found when the natural service starts.

Give the directory / var/lib/mysql write permission or maximum permission-chmod 777 / var/lib/mysql

[root@bogon lib] # mkdir mysql [root@bogon lib] # chmod 777-R mysql/

Finally:

[root@bogon lib] # service mysql startStarting MySQL... SUCCESSconfigu4 configure environment variables

Configure PATH

# vi ~ / .bash_profile

Add the following at the end of the file and use: wq to save

Export PATH=$PATH:/usr/local/mysql-5.5.60/bin

Refresh PATH

# source ~ / .bash_ profile IV. Login and configuration remote login 1 first login MySQL [root@bogon lib] # mysql-uroot-p2 * error report and solution [root@bogon lib] # mysql-uroot-pmysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

After the mysql is installed in redhad8,binary mode, the login of the mysql command is not successful. The error message is: mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory. According to Baidu's methods are not successful, should be related to the system version, and then I came up with a method: yum install libncurses*, perfect solution.

Resolve:

[root@bogon lib] # yum-y install libncurses* [root@bogon lib] # mysql-uroot-p Enter password: # enter directly to log in to Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 2Server version: 5.5.62 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > 3 modify root password mysql > use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with-ADatabase changedmysql > update user set password=password ('password to be set') where user='root' and host='localhost';Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0mysql > update user set password=password ('12345') where user='root' and host='localhost' Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0mysql > flush privileges;Query OK, 0 rows affected (0.00 sec) 4 set Telnet mysql > grant all privileges on *. * to 'root'@'%' identified by' 12345 'with grant option;Query OK, 0 rows affected (0.00 sec) mysql > FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)

If you cannot log in remotely, turn off the firewall

[root@bogon lib] # systemctl stop firewalld.service

These are the complete steps of installing MySQL5.5 for CentOS shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

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

Development

Wechat

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

12
Report