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

The method of successful login to MySQL database

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

Share

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

This article mainly introduces the successful login method of MySQL database, the contents of the article are carefully selected and edited by the author, with a certain pertinence, the reference significance for everyone is still relatively great, the following with the author to understand the successful login method of MySQL database.

You need to log in multiple times during database changes, maintenance and other work. This is explained by the database management user root@localhost. Generally, the following command line is available:

Mysql@db01: ~ $mysql-- host=localhost-- password-- port=3306-- socket=/home/3306/mysql.sock--user=root

Enter password:

If you type or paste this long list of commands every time, and then enter the password, it doesn't feel convenient and fast enough.

In MySQL 5.0,5.5 and other earlier versions, you can do the following. For illustration purposes, log in to the Linux operating system where the database resides as a mysql user (not root).

Create a hidden file .my.cnf under the mysql user's home directory, and note that the permission should be set to 600. each parameter in the above command line is written in it, which is temporarily called a login file because it is related to login, as shown below:

Mysql@db01: ~ $ls-al .my.cnf

-rw-. 1 mysql mysql 99Aug 17 21:31 .my.cnf

Mysql@db01: ~ $cat .my.cnf

[client]

Host = localhost

Password = 123456

Port = 3306

Socket = / home/3306/mysql.sock

User = root

Then type mysql (MySQL command line tool) directly in the command line, and enter to log in to the database.

In MySQL 5.6 (5.6.6) and later, with the command mysql_config_editor, you can accomplish the above requirements gracefully.

Use mysql_config_editor to create a login file, which is called the login path (loginpath) on the following command line-- mytest in login-path=mytest.

Mysql@db01: ~ $mysql_config_editor set-- host=localhost-- login-path=mytest-- password--user=root-- socket=/home/3306/mysql.sock-- port=3306

Enter password:

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

Wechat

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

12
Report