-
安装MySQL数据库:
1
|
xpleaf@leaf:~$
sudo
apt-get
install
mysql-server mysql-client libmysqlclient-dev
|
-
开启MySQL服务:
1
|
xpleaf@leaf:~$
sudo
service mysql start
|
-
登陆到MySQL数据库中:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
xpleaf@leaf:~$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection
id
is 7
Server version: 5.6.28-0ubuntu0.15.10.1 (Ubuntu)
Copyright (c) 2000, 2015, 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
|
xpleaf@leaf:~$ mysql -u root
mysql> update mysql.user
set
password = password(
'123456'
) where User =
'root'
;
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
|
1
2
3
4
5
6
7
8
9
10
11
|
mysql>
select
User, Host, Password from mysql.user;
+------------------+-----------+-------------------------------------------+
| User | Host | Password |
+------------------+-----------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | leaf | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | ::1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| debian-sys-maint | localhost | *6A368D614E978D78292FC3257D3958C6A7B241EF |
+------------------+-----------+-------------------------------------------+
5 rows
in
set
(0.00 sec)
|
1
2
|
xpleaf@leaf:~$ mysql -u root -p
Enter password:
|
1
2
3
4
5
|
mysql> delete from mysql.db where db like
'test%'
;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
|