Get the App
SLTechnology News&Howtos  ›  Database  › 

Independent installation of mysql database built in lamp or lnmp environment

Shulou Source: shulou.com Published: 2022-06-01 13:43:13 09月16日 Update

Lamp or lnmp environment is built. If mysql is installed independently, authorization is required:

Install mysql independently on a single server

After installation, optimize the server.

Authorization

Example 1:

# create user demo, password demo123

Mysql > create user demo@localhost identified by 'demo123'

Query OK, 0 rows affected (0.00 sec)

# you can only log in at this time because there is no authorization

Mysql > show grants for demo@localhost

+-+

| | Grants for demo@localhost |

+-+

| | GRANT USAGE ON *. * TO 'demo'@'localhost' IDENTIFIED BY PASSWORD' * 2CADADD54086D5EB4C9F10E0430084D7F179885C' |

+-+

1 row in set (0.00 sec)

# authorize local login

Mysql > grant all on test.* to 'demo'@'localhost'

Query OK, 0 rows affected (0.01 sec)

# check the authorization status

Mysql > show grants for demo@localhost

+-+

| | Grants for demo@localhost |

+-+

| | GRANT USAGE ON *. * TO 'demo'@'localhost' IDENTIFIED BY PASSWORD' * 2CADADD54086D5EB4C9F10E0430084D7F179885C' |

| | GRANT ALL PRIVILEGES ON `test`.* TO 'demo'@'localhost' |

+-+

2 rows in set (0.00 sec)

-

Example two

Authorize all databases to connect to myuser from the local area network 10.89.1.0

GRANT ALL PRIVILEGES ON *. * TO 'myuser'@'10.89.1.%'IDENTIFIED BY' mypassword'

FLUSH PRIVILEGES

Mysql > select user,host from mysql.user

+-+ +

| | user | host |

+-+ +

| | tom |% | |

| | tom1 |% | |

| | tom2 |% | |

| | root | 127.0.0.1 | |

| | myuser | 10.89.1% | |

| | myuser | localhost |

| | myuser | localhost |

| | root | localhost |

| | tom | localhost |

| | root | mysql |

+-+ +

10 rows in set (0.01 sec)

# client connection testing

# if it is 3306 by default, it does not need to be added. Here, multi-instance testing is used. The port is 3308.

[root@weblnmp] # mysql-umyuser-pmypassword-h 10.89.1.30-P3308

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

Your MySQL connection id is 7

Server version: 5.5.32-log Source distribution

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

5.web server connection test

[root@weblnmp blog] # vi test_mysql.php

Tags: Instance server service test standalone login data database environment client client password local area local area network situation user port network segment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Docker Shulou Information NVidia Shulou Tech Info