mysql5.5 localhost和'%'的区别

mysql5.5 localhost和'%'的区别,第1张

mysql5.5 localhost和'%'的区别

MySQL 127.0.0.1和localhost本质区别

登录方式:

1

2

[root@10-4-14-168 ~]# mysql -uroot -p

Enter password:

查看权限表

1

2

3

4

5

6

7

8

9

10

mysql>SELECT user,host,password FROM mysql.user

+------+-------------+-------------------------------------------+

| user | host| password |

+------+-------------+-------------------------------------------+

| root | localhost | *11B9ACA21786F766739D0EB1483C5F64212B81AC |

| root | 10.4.14.168 | *11B9ACA21786F766739D0EB1483C5F64212B81AC |

| root | 127.0.0.1 | *11B9ACA21786F766739D0EB1483C5F64212B81AC |

| root | ::1 | *11B9ACA21786F766739D0EB1483C5F64212B81AC |

+------+-------------+-------------------------------------------+

4 rows in set (0.00 sec)

查看当前的IP地址:

1

inet addr:10.4.14.168

验证一下三种登陆方式:

1

# mysql -h localhost -uroot -p<br>可以登陆

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

mysql>status

--------------

mysql Ver 14.14 Distrib 5.5.39, for Linux (x86_64) using readline 5.1

Connection id: 6

Current database:

Current user: root@localhost

SSL:Not in use

Current pager: stdout

Using outfile: ''

Using delimiter:

Server version: 5.5.39-cll-lve MySQL Community Server (GPL) by Atomicorp

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset:latin1

Db characterset:latin1

Client characterset:utf8

Conn. characterset:utf8

UNIX socket:/var/lib/mysql/mysql.sock

Uptime: 19 min 8 sec

Threads: 1 Questions: 24 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.020

--------------

1

# mysql -h 127.0.0.1 -uroot -p

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

mysql>status

--------------

mysql Ver 14.14 Distrib 5.5.39, for Linux (x86_64) using readline 5.1

Connection id: 4

Current database:

Current user: root@localhost

SSL:Not in use

Current pager: stdout

Using outfile: ''

Using delimiter:

Server version: 5.5.39-cll-lve MySQL Community Server (GPL) by Atomicorp

Protocol version: 10

Connection: 127.0.0.1 via TCP/IP

Server characterset:latin1

Db characterset:latin1

Client characterset:utf8

Conn. characterset:utf8

TCP port: 3306

Uptime: 2 min 24 sec

Threads: 2 Questions: 21 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.145

--------------

1

<br># mysql -h 10.4.14.168 -uroot -p

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

mysql>status

--------------

mysql Ver 14.14 Distrib 5.5.39, for Linux (x86_64) using readline 5.1

Connection id: 5

Current database:

Current user: root@10-4-14-168

SSL:Not in use

Current pager: stdout

Using outfile: ''

Using delimiter:

Server version: 5.5.39-cll-lve MySQL Community Server (GPL) by Atomicorp

Protocol version: 10

Connection: 10.4.14.168 via TCP/IP

Server characterset:latin1

Db characterset:latin1

Client characterset:utf8

Conn. characterset:utf8

TCP port: 3306

Uptime: 3 min 9 sec

Threads: 2 Questions: 30 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.158

--------------

# mysql -uroot -p

Enter password:

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

Your MySQL connection id is 7

Server version: 5.5.39-cll-lve MySQL Community Server (GPL) by Atomicorp

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

--------------

mysql Ver 14.14 Distrib 5.5.39, for Linux (x86_64) using readline 5.1

Connection id: 7

Current database:

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile: ''

Using delimiter:

Server version: 5.5.39-cll-lve MySQL Community Server (GPL) by Atomicorp

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: latin1

Db characterset: latin1

Client characterset: utf8

Conn. characterset: utf8

UNIX socket: /var/lib/mysql/mysql.sock

Uptime: 22 min 31 sec

Threads: 1 Questions: 31 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.022

--------------

在redhat6.5上安装mysql的方法

下载mysql5.5的安装包。这里下载的是MySQL-5.5.39-2.el6.x86_64.rpm-bundle.tar

解压mysql5.5的安装包

tar -xvf MySQL-5.5.39-2.el6.x86_64.rpm-bundle.tar

注意的是要切换的root用户  使用 su root切换用户

解压之后就是出现了好多的rpm文件

在这些文件中我们要安装的就是下面的3个,这个地方注意了。

MySQL-client-5.5.39-2.el6.x86_64.rpm

MySQL-devel-5.5.39-2.el6.x86_64.rpm

MySQL-server-5.5.39-2.el6.x86_64.rpm

安装过程较快,除了MySQL-server-5.5.39-2.el6.x86_64.rpm稍微慢一些。

其他两个十分的快

使用的命令是

rpm - ivh   *.rpm

接着就是初始化数据库。十分简单

/usr/bin/mysql_install_db

接下来就是查看mysql的状态,并设置mysql的初始密码,见下图。

好了,5步下来我们的mysql就安装完毕。是不是很简单啊。哈哈

下载mysql5.5的安装包。这里下载的是MySQL-5.5.39-2.el6.x86_64.rpm-bundle.tar 解压mysql5.5的安装包 tar -xvf MySQL-5.5.39-2.el6.x86_64.rpm-bundle.tar 注意的是要切换的root用户 使用 su root切换用户 解压之后就是出现了好多的rpm文件


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/8490382.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-17
下一篇 2023-04-17

发表评论

登录后才能评论

评论列表(0条)

保存