Kali 配置 mysql

1、如果Linux中未安装MySQL,则需要下载安装,在安装的过程中会要求输入用户名密码,则无需重置,直接设置



2、MySQL设置UTF-8编码格式

配置文件:

[python] view plain copy
 print?
  1. root@kali:~# vim /etc/mysql/my.cnf  

添加默认utf-8编码:
[python] view plain copy
 print?
  1. [client]  
  2. default-character-set = utf8  
  3.   
  4. [mysqld]  
  5. default-storage-engine = INNODB  
  6. character-set-server = utf8  
  7. collation-server = utf8_general_ci  



3、更新MySQL的用户名密码


首先查看MySQL是否运行,确保MySQL是stop状态,可以使用/etc/init.d/mysql stop停止运行

[python] view plain copy
 print?
  1. root@kali:~# /etc/init.d/mysql status  
  2. [info] MySQL is stopped..  


然后启动MySQL的server/daemon process

[python] view plain copy
 print?
  1. root@kali:~# mysqld_safe --skip-grant-tables &  
  2. [14216  
  3. root@kali:~# 151015 11:33:52 mysqld_safe Logging to syslog.  
  4. 151015 11:33:52 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql  

使用root用户连接MySQL

[python] view plain copy
 print?
  1. root@kali:~# mysql -u root  
  2. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  3. Your MySQL connection id is 1  
  4. Server version: 5.5.44-0+deb7u1 (Debian)  
  5.   
  6. Copyright (c) 20002015, Oracle and/or its affiliates. All rights reserved.  
  7.   
  8. Oracle is a registered trademark of Oracle Corporation and/or its  
  9. affiliates. Other names may be trademarks of their respective  
  10. owners.  
  11.   
  12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  13.   
  14. mysql>   

更改root用户的密码为admin

[python] view plain copy
 print?
  1. mysql> use mysql  
  2. Reading table information for completion of table and column names  
  3. You can turn off this feature to get a quicker startup with -A  
  4.   
  5. Database changed  
  6. mysql> update user set password=PASSWORD('admin') where User='root';  
  7. Query OK, 4 rows affected (0.01 sec)  
  8. Rows matched: 4  Changed: 4  Warnings: 0  

执行更新命令

[python] view plain copy
 print?
  1. mysql> flush privileges;  
  2. Query OK, 0 rows affected (0.00 sec)  
flush privileges 命令本质上的作用是将当前user和privilige表中的用户信息/权限设置从mysql库(MySQL数据库的内置库)中提取到内存里。MySQL用户数据和权限有修改后,希望在"不重启MySQL服务"的情况下直接生效,那么就需要执行这个命令。通常是在修改ROOT帐号的设置后,怕重启后无法再登录进来,那么直接flush之后就可以看权限设置是否生效。而不必冒太大风险。


退出

[python] view plain copy
 print?
  1. mysql> quit  


4、验证用户密码是否更新成功


重启MySQL

[python] view plain copy
 print?
  1. root@kali:~# /etc/init.d/mysql restart  
  2. [ ok ] Stopping MySQL database server: mysqld.  
  3. [....] Starting MySQL database server: mysqld151015 11:41:36 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended  
  4. [ .k   
  5. [info] Checking for tables which need an upgrade, are corrupt or were   
  6. not closed cleanly..  
  7. [1]+  完成                  mysqld_safe --skip-grant-tables  

使用root用户连接MySQL

[python] view plain copy
 print?
  1. root@kali:~# mysql -u root -p  
  2. Enter password:   
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  4. Your MySQL connection id is 43  
  5. Server version: 5.5.44-0+deb7u1 (Debian)  
  6.   
  7. Copyright (c) 20002015, Oracle and/or its affiliates. All rights reserved.  
  8.   
  9. Oracle is a registered trademark of Oracle Corporation and/or its  
  10. affiliates. Other names may be trademarks of their respective  
  11. owners.  
  12.   
  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  14.   
  15. mysql>   

原文链接: Kali 配置 mysql 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( http://gyarmy.com/post-196.html )

发表评论

0则评论给“Kali 配置 mysql”