博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS下设置MySQL的root密码
阅读量:4171 次
发布时间:2019-05-26

本文共 798 字,大约阅读时间需要 2 分钟。

CentOS刚装的MySQL一般需要重设MySQL密码,可以用以下方法重设。 
方法一、 
Js代码  
# /etc/init.d/mysqld stop  
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &  
# mysql -u root mysql   
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';   
mysql> FLUSH PRIVILEGES;   
mysql> quit  
# /etc/init.d/mysql restart  
# mysql -uroot -p   
Enter password: <输入新设的密码newpassword>   
mysql>  
方法二、 
Js代码  
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:  
# mysql -udebian-sys-maint -p   
Enter password: <输入[client]节的密码>   
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';   
mysql> FLUSH PRIVILEGES;   
mysql> quit  
# mysql -uroot -p   
Enter password: <输入新设的密码newpassword>   

mysql>  

支持远程访问:

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';   --%可以改成ip或者其他
mysql>select host, user from user;    

重启数据库

参考:

转载地址:http://syyai.baihongyu.com/

你可能感兴趣的文章
分析若干没面试机会和没体现实力的简历
查看>>
用python的matplotlib和numpy库绘制股票K线均线
查看>>
以互联网公司的经验告诉大家,架构师究竟比高级开发厉害在哪?
查看>>
GanttProject 使用的控件第三方包:jdnc-modifBen.jar
查看>>
ps、grep和kill联合使用杀掉进程
查看>>
openfire中的mina框架使用
查看>>
去掉Windows Messager的自动登录
查看>>
dspace可以检索中文了
查看>>
利用Eclipse编辑中文资源,配置文件
查看>>
将中文转为unicode 及转回中文函数
查看>>
《程序员》专访金蝶:是谁不相信国产软件?
查看>>
debian的gnome下的xmms乱码解决方案
查看>>
python切片操作
查看>>
python 中的split()函数和os.path.split()函数
查看>>
python 矩阵转置
查看>>
python 使用zip合并相邻的列表项
查看>>
python iter( )函数
查看>>
Python 迭代器(iterator)
查看>>
Python enumerate类
查看>>
leetcode 99 Recover Binary Search Tree (python)
查看>>