Fedora 20下 MySQL 的安装(二)

2014-11-24 17:34:11 · 作者: · 浏览: 1
nbsp;                    1/3 
  验证中      : community-mysql-server-5.5.35-1.fc20.x86_64                 2/3 
  验证中      : community-mysql-common-5.5.35-1.fc20.x86_64                 3/3 


已安装:
  community-mysql-server.x86_64 0:5.5.35-1.fc20                                 


作为依赖被安装:
  community-mysql.x86_64 0:5.5.35-1.fc20                                        
  community-mysql-common.x86_64 0:5.5.35-1.fc20                                 


完毕!
[root@rachel densintian]# systemctl start mysqld.service
[root@rachel densintian]# systemctl enable mysqld.service
ln -s '/usr/lib/systemd/system/mysqld.service' '/etc/systemd/system/multi-user.target.wants/mysqld.service'
[root@rachel densintian]# mysql -u root  #以root登陆数据库
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.35 MySQL Community Server (GPL)


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> select user, host, password from mysql.user;   #user列表
+------+-----------+----------+
| user | host      | password |
+------+-----------+----------+
| root | localhost |          |
| root | rachel    |          |
| root | 127.0.0.1 |          |
| root | ::1       |          |
|      | localhost |          |
|      | rachel    |          |
+------+-----------+----------+
6 rows in set (0.00 sec)


mysql> delete from mysql.user where user=''; #删除空user
Query OK, 2 rows affected (0.00 sec)


mysql> delete from mysql.user where user='root' and host='::1'; #删除IPv6用户(如果不用的话)
Query OK, 1 row affected (0.00 sec)


mysql> select user, host, password from mysql.user;
+------+-----------+----------+
| user | host      | password |
+------+-----------+----------+
| root | localhost |          |
| root | rachel    |          |
| root | 127.0.0.1 |          |
+------+-----------+----------+
3 rows in set (0.00 sec)


# 设定密码
mysql> set password for root@localhost=password('XXXXXX');
Query OK, 0 rows affected (0.00 sec)


mysql> set password for root@rachel=password('XXXXXX');
Query OK, 0 rows affected (0.00 sec)


mysql> set password for root@'127.0.0.1'=password('XXXXXXX');
Query OK, 0 rows affected (0.00 sec)


#再次列密码
mysql> select user, host, password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *C7E2F6338326EDC0AXXXXXXXXXXXXXXXXXXXXXXX |
| root | rachel    | *C7E2F6338326EDC0AXXXXXXXXXXXXXXXXXXXXXXX |
| root | 127.0.0.1 | *C7E2F6338326EDC0AXXXXXXXXXXXXXXXXXXXXXXX |
+------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)


mysql> exit
Bye
[root@rachel densintian]# mysql -u root -p #再次登录
Enter password:                            #输入刚才的密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.35 MySQL Community Server (GPL)


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> exit
Bye
[root@rachel densintian]#