-
查看是否已经安装MySQL:
1
|
[root@leaf]
# yum list installed | grep mysql
|
-
安装MySQL数据库:
1
|
[root@leaf ~]
# yum -y install mysql-server mysql mysql-devel
|
-
查看安装的MySQL信息:
1
2
3
4
5
|
[root@leaf ~]
# yum list installed | grep mysql
mysql.x86_64 5.1.73-5.el6_6 @base
mysql-devel.x86_64 5.1.73-5.el6_6 @base
mysql-libs.x86_64 5.1.73-5.el6_6 @base
mysql-server.x86_64 5.1.73-5.el6_6 @base
|
-
开启MySQL服务:
1
2
|
[root@leaf ~]
# service mysqld start
Starting mysqld: [ OK ]
|
-
登陆到MySQL数据库中:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@leaf ~]
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection
id
is 4
Server version: 5.1.73 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>
|
1
2
3
4
5
6
7
|
[root@leaf ~]
# mysql -u root
mysql> update mysql.user
set
password = password(
'123456'
) where User =
'root'
;
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
|
-
先使用刚刚创建的密码登陆到MySQL中:
1
2
3
4
|
[root@leaf ~]
# mysql -u root -p
Enter password:
mysql>
|
-
删除匿名用户:
1
2
3
4
5
6
7
|
mysql> DROP USER
''
@
'localhost'
;
Query OK, 0 rows affected (0.00 sec)
mysql> DROP USER
''
@
'leaf'
;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
|
1
2
3
4
5
6
7
8
9
|
mysql>
select
User, Host, Password from mysql.user;
+------+-----------+-------------------------------------------+
| User | Host | Password |
+------+-----------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | leaf | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+------+-----------+-------------------------------------------+
3 rows
in
set
(0.00 sec)
|
1
2
3
4
5
6
7
8
|
mysql> delete from mysql.db where db like
'test%'
;
Query OK, 2 rows affected (0.00 sec)
mysql> drop database
test
;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
|