mysql数据库安装完成后,mysql默认root用户没有密码
1.修改密码
数据库安装目录:/user/local/mysql
[root@AY13052612210820701aZ bin]/user/local/mysql/bin/mysql mysql -u root
MariaDB [mysql]> UPDATE user SET Password=PASSWORD('newpwd') WHERE User='root';
MariaDB [mysql]>FLUSH PRIVILEGES;
MariaDB [mysql]>exit;
密码修改完成后重新登录
[root@AY13052612210820701aZ bin]/user/local/mysql/bin/mysql
mysql -u root -p
注意:要带上p参数,需要密码登录,否则提示错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 74
Server version: 5.5.31-MariaDB-log Source distribution
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [mysql]>
成功登录
本文详细介绍了在MySQL数据库安装完成后,如何修改默认root用户的密码。包括在特定目录下执行命令更新密码,并通过FLUSH PRIVILEGES刷新权限。密码修改后,重新使用新密码登录数据库。
1345

被折叠的 条评论
为什么被折叠?



