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-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces how to install MySQL, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

1. Binary installation on Linux (take version 5.6 as an example)

1. New user

Useradd mysql

two。 Download the unzip installation package

Cd / usr/local/

Tar zxf mysql-VERSION-OS.tar.gz

Ln-s mysql-VERSION-OS mysql

Chown-R mysql:mysql mysql

3. Configure the simplest parameter file so that the configuration is sufficient to start, and then add it according to the system configuration and project needs.

Vi / etc/my.cnf

[client]

[mysqld]

Server-id=11

Port = 3306

User = mysql

Character-set-server=utf8

Socket = / tmp/mysql.sock

Basedir = / usr/local/mysql

Datadir = / data/mysqldata/

[mysql]

4. Initialization

Cd / usr/local/mysql

. / scripts/mysql_install_db-user=mysql-datadir=/data/mysqldata/

5. Start

. / bin/mysqld_safe-- defaults-file=/etc/my.cnf &

6. View the process

Ps-ef | grep mysql

II. Installation on windows system

Source: http://jingyan.baidu.com/article/f3ad7d0ffc061a09c3345bf0.html

There are two types of MySQL installation files, one is in msi format and the other is in zip format. If it is in msi format, you can click to install it and follow the installation prompts it gives (I believe you can read the English prompts in English). Generally, MySQL will be installed in C:\ Program Files\ MySQL\ MySQL Server 5.6; zip format is extracted by yourself, and MySQL can be used after decompression, but it needs to be configured.

1. Download the mysql-5.6.32-winx64.zip file

two。 Decompress mysql-5.6.32-winx64.

3. Put the extracted files into D:\ Program Files (x86)\

4. Change its name to mysql

5. Configure environment variables

My computer-> Properties-> Advanced-> Environment variables

Select PATH and add after it: the path to your mysql bin folder (for example: C:\ Program Files\ MySQL\ MySQL Server 5.6\ bin)

PATH=.;C:\ Program Files\ MySQL\ MySQL Server 5.6\ bin (note that it is appended, not overwritten)

6.

Don't rush to start mysql after configuring the environment variables, we also need to modify the configuration file (if there is no configuration, the error in the figure will occur when starting later! Error 2: the file cannot be found by the system. The default configuration file for mysql-5.6.1X is in C:\ Program Files\ MySQL\ MySQL Server 5.6\ my-default.ini, or create a my.ini file yourself.

Modify or add a configuration to it:

[mysqld]

Basedir=C:\ Program Files\ MySQL\ MySQL Server 5.6 (the directory where mysql resides)

Datadir=C:\ Program Files\ MySQL\ MySQL Server 5.6\ data (directory where mysql is located)

7.

Run cmd as an administrator (be sure to run as an administrator, otherwise there are not enough privileges)

Enter: cd C:\ Program Files\ MySQL\ MySQL Server 5.6\ bin to enter the bin folder of mysql (no matter whether you have configured the environment variable or not, enter the bin folder, otherwise you will still report error 2 after starting the service)

Enter mysqld-install (if you do not run as an administrator, there will be an error due to insufficient permissions: Install/Remove of the Service Denied!)

Installation succeeded

8.

After the installation is successful, the service will be started. Continue to type: net start mysql in cmd, and the service will start successfully! (close the command net stop mysql accordingly)

At this time, many people will make mistakes, please note:

Note: error 2 and error 1067 often occur at this time.

If "error 2 system cannot find the file", check whether the configuration file has been modified or if you have entered the bin directory. If the configuration file has been modified correctly and entered the bin folder, you need to delete mysql (enter mysqld-remove) and then reinstall (enter mysqld-install).

If error 1067 occurs, it is a configuration file modification error to verify that the configuration file is correct.

9.

After the service starts successfully, you can log in. Enter mysql-u root-p (no password for the first login, press enter directly), and the login is successful!

10.

After login, operate the same command line as linux.

Finally, attached.

Installation process for version 5.7

The binary installation process of the official website

Shell > groupadd mysql

Shell > useradd-r-g mysql-s / bin/false mysql

Shell > cd / usr/local

Shell > tar zxvf / path/to/mysql-VERSION-OS.tar.gz

Shell > ln-s full-path-to-mysql-VERSION-OS mysql

Shell > cd mysql

Shell > mkdir mysql-files

Shell > chmod 750mysql-files

Shell > chown-R mysql.

Shell > chgrp-R mysql.

Shell > bin/mysql_install_db-- user=mysql # Before MySQL 5.7.6

Shell > bin/mysqld-- initialize-- user=mysql # MySQL 5.7.6 and up

# add this parameter-- initial-insecure, and an empty password will be generated, so you don't have to look for it in errorlog

Mysqld-initialize-user=mysql-basedir=/usr/local/mysql-datadir=/data/mysql

# you cannot add-defaults-file=/etc/my.cnf here. This parameter is not recognized, and an error is reported in the error log.

Shell > bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up

Chmod + r ca-key.pem client-key.pem server-key.pem private_key.pem

# otherwise the error log will report an error

Shell > chown-R root.

Shell > chown-R mysql data mysql-files

Shell > bin/mysqld_safe-- user=mysql &

# Next command is optional

Shell > cp support-files/mysql.server / etc/init.d/mysql.server

Thank you for reading this article carefully. I hope the article "how to install MySQL" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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