1、如果Linux中未安装MySQL,则需要下载安装,在安装的过程中会要求输入用户名密码,则无需重置,直接设置
2、MySQL设置UTF-8编码格式
配置文件:
添加默认utf-8编码:
[client]
default-character-set = utf8
[mysqld]
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci
3、更新MySQL的用户名密码
首先查看MySQL是否运行,确保MySQL是stop状态,可以使用/etc/init.d/mysql stop停止运行
root@kali:~
[info] MySQL is stopped..
然后启动MySQL的server/daemon process
root@kali:~
[1] 4216
root@kali:~
151015 11:33:52 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
使用root用户连接MySQL
root@kali:~
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.44-0+deb7u1 (Debian)
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>
更改root用户的密码为admin
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=PASSWORD('admin') where User='root';
Query OK, 4 rows affected (0.01 sec)
Rows matched: 4 Changed: 4 Warnings: 0
执行更新命令
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
flush privileges 命令本质上的作用是将当前user和privilige表中的用户信息/权限设置从mysql库(MySQL数据库的内置库)中提取到内存里。MySQL用户数据和权限有修改后,希望在"不重启MySQL服务"的情况下直接生效,那么就需要执行这个命令。通常是在修改ROOT帐号的设置后,怕重启后无法再登录进来,那么直接flush之后就可以看权限设置是否生效。而不必冒太大风险。
退出
4、验证用户密码是否更新成功
重启MySQL
root@kali:~
[ ok ] Stopping MySQL database server: mysqld.
[....] Starting MySQL database server: mysqld151015 11:41:36 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[ .k
[info] Checking for tables which need an upgrade, are corrupt or were
not closed cleanly..
[1]+ 完成 mysqld_safe --skip-grant-tables
使用root用户连接MySQL
root@kali:~
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.5.44-0+deb7u1 (Debian)
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>