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 mysql

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

Share

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

This article mainly shows you "how to install mysql", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to install mysql" this article.

Download the installation package

1. Download hive http://mirrors.hust.edu.cn/apache/ to get apache-hive-1.1.0.tar.gz, and put it in this directory / home/

2. Download mysql https://dev.mysql.com/downloads/file/?id=471503 to get

My linux version is 6.8. It is best to choose the glib version when downloading. If you download various other packages, it will prompt various dependencies, which is troublesome.

Copy to this directory / mysql/

Second, install mysql

1. Uninstall the mysql-related installation packages that come with the system, and uninstall only the packages at the beginning of mysql

Rpm-qa | grep-I mysql

Rpm-ev mysql-community-libs-5.7.19-1.el7.x86_64-nodeps

two。 Create users and groups

Groupadd mysql

Useradd-r-g mysql mysql

3. Installation

Extract tar-zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz-C.. / usr/local

Modify the directory [root@hadoop local] # mv mysql-5.7.19-linux-glibc2.12-x86_64/ mysql

Add authorization [root@hadoop mysql] # chown-R mysql.mysql / usr/local/mysql

Create a new data directory [root@hadoop mysql] # mkdir data

4. Install. / bin/mysqld-- initialize-- user=mysql-- basedir=/usr/local/mysql-- datadir=/usr/local/mysql/data

Notice the last line, which is also different from the version, which gives root an initial password, which is the root user of mysql, which will be used later when logging in. # Hangjia Magazine Els4G &

4. Change all the files in the mysql/ directory except the data/ directory back to the root user, and the mysql user only needs to be the owner of all files in the mysql/data/ directory.

[root@hadoop mysql] # chown-R root.

[root@hadoop mysql] # chown-R mysql data

5. Create a tmp folder and authorize

[root@hadoop mysql] # mkdir tmp

[root@hadoop mysql] # chown-R mysql:mysql tmp

6. Copy and edit the configuration file

[root@hadoop etc] # cp my.cnf.rpmsave my.cnf

[root@hadoop etc] # vi my.cnf

7. Add the following

Basedir = / usr/local/mysql

Datadir = / usr/local/mysql/data

Port = 3306

Socket = / usr/local/mysql/tmp/mysql.sock

Sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

8. Copy mysql.server to / etc/init.d/mysql

[root@hadoop support-files] # cp mysql.server / etc/init.d/mysql

[root@hadoop init.d] # chmod + x mysql

9. Register mysql as a boot service

[root@hadoop init.d] # chkconfig-- add mysql

[root@hadoop init.d] # chkconfig-- list mysql

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

10. Start

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

Starting MySQL.Logging to'/ usr/local/mysql/data/hadoop.err'.

. [OK]

11. Modify environment variabl

Export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:/usr/local/mysql:/usr/local/mysql/bin

[root@hadoop init.d] # source / etc/profile

twelve。 Error logging in to the Times using root

[root@hadoop init.d] # mysql-uroot-p # Happy Magnum Els4G &

Enter password:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/ tmp/mysql.sock' (2)

13. Modify / etc/my.cnf file to supplement mysql and client configuration

[mysqld]

Basedir = / usr/local/mysql

Datadir = / usr/local/mysql/data

Port = 3306

Socket = / usr/local/mysql/tmp/mysql.sock

Sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

Skip-grant-tables

[mysql]

Default-character-set=utf8

Socket = / usr/local/mysql/tmp/mysql.sock

[client]

Default-character-set=utf8

Socket = / usr/local/mysql/tmp/mysql.sock

14. Log in again and enter a new password

[root@hadoop etc] # mysql-uroot-p # Happy Magnum Els4G &

Enter password: mysql

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

Your MySQL connection id is 3

Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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 >

Opening and closing of 15.mysql service

# / etc/init.d/mysql start or serivce mysql start or bin/mysqld_safe&

# / etc/init.d/mysql stop or service mysql stop or bin/mysqladmin-uroot-p

3. If you add a hive user, you will get the following error

Mysql > create user 'hive'@'%' identified by' hive'

ERROR 1290 (HY000): The MySQL server is running with the-- skip-grant-tables option so it cannot execute this statement

Force write out

Mysql > flush privileges

Re-execute

Mysql > create user 'hive'@'%' identified by' hive'

Query OK, 0 rows affected (0.00 sec)

Mysql > select host,user from user

+-+ +

| | host | user |

+-+ +

| |% | hive |

| | localhost | mysql.session |

| | localhost | mysql.sys |

| | localhost | root |

+-+ +

4 rows in set (0.00 sec)

The above is all the contents of the article "how to install mysql". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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

Database

Wechat

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

12
Report