当前位置:Gxlcms > 数据库问题 > MySQL安装及初始化

MySQL安装及初始化

时间:2021-07-01 10:21:17 帮助过:3人阅读

 

4、Linux下密码破解

 1 [root@db01 mysql]# vim my.cnf
 2 [mysql]
 3 user=root
 4 password=123456
 5 [mysqld]
 6 skip-grant-tables                #在my.cnf文件中加上这句(跳过mysql授权表)  
7
8 [root@db01 mysql]# /etc/init.d/mysqld restart #重启MySQL服务
9 [root@db01 mysql]# mysql #登录MySQL
10 mysql> select user(); #查看登录用户是否为root
11 +--------+
12 | user() |
13 +--------+
14 | root@ |
15 +--------+
16 1 row in set (0.00 sec)
17
18 mysql> update mysql.user set password=password("123") where user="root" and host="localhost"; #修改密码为123
19 mysql> flush privileges;

注:windows下密码破解可以使用和Linux上相同的方法
windows下另外破解密码方法
          1 C:\Users\test>net stop mysql
          2 C:\Users\test>mysqld --skip-grant-tables
          3 C:\Users\test>mysql
          4 mysql> update mysql.user set authentication_string=password(‘‘) where user = ‘root‘;
          5 mysql> flush privileges;
          6 C:\Users\test>net start mysql

 

 

5、指定登录用户名和密码和查看MySQL字符集

 1 C:\Users\test>mysql -uroot -p123456
 2 mysql> select user();
 3 +----------------+
 4 | user()         |
 5 +----------------+
 6 | root@localhost |
 7 +----------------+
 8 1 row in set (0.00 sec)
 9 mysql> show variables like ‘%char%‘;       #查看数据库字符集
10 +--------------------------+-------------------------------------------+
11 | Variable_name | Value |
12 +--------------------------+-------------------------------------------+
13 | character_set_client | utf8 |
14 | character_set_connection | utf8 |
15 | character_set_database | latin1 |
16 | character_set_filesystem | binary |
17 | character_set_results | utf8 |
18 | character_set_server | latin1 |
19 | character_set_system | utf8 |
20 | character_sets_dir | /application/mysql-5.6.35/share/charsets/ |
21 +--------------------------+-------------------------------------------+
22 8 rows in set (0.02 sec)

 

6、mysql客户端免输入用名密码登录及修改默认字符集

     在mysql配置文件中加上(windows上为my.ini,Linux上为my.cnf)

    技术分享图片

[mysql]
default-character-set=utf8
user=root
password=123456
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
skip-grant-tables                 

C:\Users\Jun>mysql                 #登录MySQL
mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

 

MySQL安装及初始化

标签:share   linux   win   app   https   技术   登陆   ati   mysqld   

人气教程排行