如何修改MySql数据库的用户名和密码?

如何修改MySql数据库的用户名和密码?,第1张

修改mysql数据库的用户密码

更改密码

1、mysql -u root -p

2、Enter password:***

3、mysql>use mysql  #选择数据库

4、Database changed

5、mysql>UPDATE user SET password=PASSWORD("新密码") WHERE user='你的用户名'

6、mysql>FLUSH PRIVILEGES

7、mysql>quit

更改用户名: 

1、mysql -u root -p

2、Enter password:***

3、mysql>use mysql  #选择数据库

4、Database changed

5、mysql>update user set user="新用户名" where user="root"#将用户名为root的改为新用户名

6、mysql>flush privileges#刷新权限

7、mysql> exit

扩展资料:

mysql常用命令:

安装(基于centos)

yum -y install mariadb mariadb-server #centos7版本

yum -y install mysql mysql-server #centos7以下版本

启动

service mysqld start #开启 centos7以下版本

chkconfig mysqld on #设置开机自启

OR

systemctl start mariadb #centos7

systemctl enable mariadb

设置密码

1 、mysqladmin -u root -p123 password '1234' #修改root用户密码

2、进入mysql库修改user表

mysql>use mysql

mysql>update user set password=password('你的密码') where user='root'

mysql>flush privileges

登录

mysql #本地登录,默认用户root,空密码,用户为root@127.0.0.1

mysql -uroot -p1234 #本地登录,指定用户名和密码,用户为root@127.0.0.1

mysql -uroot P端口号 -h 192.168.31.95 -p密码 #远程登录,用户为root@192.168.31.95

查看

ps aux |grep mysqld #查看进程

netstat -an |grep 3306 #查看端口

可以修改:

1、用root身份登入 进入mysql库 修改user表即可。

2、 *** 作如下:

G:\phpStudy\MySQL\bin>mysql -uroot -proot

Welcome to the MySQL monitor. Commands end with or \g.

Your MySQL connection id is 391

Server version: 5.0.51b-community-nt-log MySQL Community Edition (GPL)

Type 'help' or '\h' for help. Type '\c' to clear the buffer.

mysql>use mysql

Database changed

mysql>update user set user='xly' where user='root'

Query OK, 2 rows affected (0.00 sec)

Rows matched: 2 Changed: 2 Warnings: 0

mysql>flush privileges

mysql>select user,host,password from mysql.user

+------+-----------+-------------------------------------------+

| user | host | password |

+------+-----------+-------------------------------------------+

| xly | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

| yxl | localhost | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |

| xly | % | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |

+------+-----------+-------------------------------------------+

3 rows in set (0.00 sec)

运行CMD,

cd:

\APMServ5.2.6\MySQL5.1\bin

./mysqladmin

-u

root

-p

password

'newpassword'

实际上这个命令是这么用的,

假如你原来的

密码

是123

打算修改成456

那么你需要使用这样的命令

./mysqladmin

-u

root

-p

password

'456'

然后系统会询问

你现在

的密码,你输入现在的密码123回车就可以了

下次使用MYSQL的时候,ROOT

的口令就是456了

还有一种方法是通过http直接访问修改密码

下面的

网址

是修改密码的视频教程,你看一下好了!


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/6932952.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-03-30
下一篇2023-03-30

发表评论

登录后才能评论

评论列表(0条)

    保存