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

A simple way to install MySQL in an enterprise environment

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

The following is followed by the author to understand the simple method used in the installation of MySQL in the enterprise environment. I believe everyone will benefit a lot after reading it. The text is not much in the essence. I hope that the simple method used in the installation of MySQL in the enterprise environment is what you want.

MySQL installation in an enterprise environment usually uses two methods

1. MySQL binary installation package mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

2. Install mysql-5.6.33.tar.gz in MySQL source package

Difference:

The binary package is easy to install and does not need to be compiled. It can be used by direct decompression. But the binary package is larger than the source package. Here's how to install the MySQL binary installation package. (please give us a lot of advice on what is not well written.)

1. Add mysql users

Useradd mysql-s / sbin/nologin-M

Parameter description:-s / sbin/nologin means the user is prohibited from logging in

-M does not need to create a home directory.

2. Create a directory mkdir / application

Explanation: the binary MySQL installation package is installed by default under / usr/local, this directory can not be created, this is just a personal habit. The habit of the operation and maintenance staff is to follow the old path and avoid new holes.

3. Extract the installation package

Tar-xvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

4. Rename the extracted file

Mv mysql-5.6.33-linux-glibc2.5-x86_64 / application/mysql-5.6.33

5. Establish a soft connection

Ln-s / application/mysql-5.6.33 / application/mysql

6. Modify the master and group of MySQL

Chown-R mysql.mysql / application/mysql/

7. Initialize the database

/ application/mysql/scripts/mysql_install_db-basedir=/application/mysql-datadir=/application/mysql/data/-user=mysql

8. Copy the MySQL startup script

Cp / application/mysql/support-files/mysql.server / etc/init.d/mysqld

9. Add execution permission to the startup script

Chmod + x / etc/init.d/mysqld

10. The default installation path of the binary installation package is / usr/local, so replace / usr/local in the script with / application

11. Start MySQL

/ etc/init.d/mysqld start

Starting MySQL... . [OK]

If the following error is reported:

Starting MySQL.180223 17:46:06 mysqld_safe Directory'/ var/lib/mysql' for UNIX socket file don't exists.

The server quit without updating PID file (/ var/lib/mysql/ I [failed] 3fkghffrq11dqZ.pid).

Rename the / etc/my.cnf file

12. Check whether MySQL is really started

Netstat-nplt | grep 3306

Tcp 0 0: 3306: * LISTEN 15064/mysqld

13. If you find that the MySQL port is not started, please check the / application/mysql/data/.err log and debug according to the error message.

Vim / application/mysql/data/.err

14. Set MySQL to boot automatically

Chkconfig-add mysqld

Chkconfig mysqld on

15. Set global variables

Vim / etc/profile

Add at the end of the document

Export PATH=/application/mysql/bin:$PATH

16. Log in to MySQL. You can log in without a password at this time, and you are a root user.

[root@Jhyeliu data] # mysql

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

Your MySQL connection id is 1

Server version: 5.6.33 MySQL Community Server (GPL)

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

17. Reinitialize the data if the following occurs.

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

1) Delete the initialized data directory rm-rf / application/mysql/data

2), reinitialize

18. MySQL security reinforcement

Set the password for the root user

Mysqladmin-u root password' password'

19. Clean up useless libraries

Drop database test

20. Clean up useless users

Select user,host from mysql.user

+-+ +

| | user | host |

+-+ +

| | root | 127.0.0.1 | |

| | root |:: 1 |

| | jhyeliu |

| | root | jhyeliu |

| | localhost |

| | root | localhost |

+-+ +

Drop user "root" @ ":: 1"

Query OK, 0 rows affected (0.05 sec)

Drop user "@" localhost "

Query OK, 0 rows affected (0.00 sec)

Drop user "@" jhyeliu "

Query OK, 0 rows affected (0.00 sec)

Drop user "root" @ "jhyeliu"

Query OK, 0 rows affected (0.00 sec)

Select user,host from mysql.user

+-+ +

| | user | host |

+-+ +

| | root | 127.0.0.1 | |

| | root | localhost |

+-+ +

Flush privileges

At this point, the MySQL database is basically complete.

After reading this article on simple ways to install MySQL in an enterprise environment, many readers will want to know more about it. For more industry information, you can follow our industry information section.

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

Servers

Wechat

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

12
Report