+-----------+
输入mysql进行登陆!
接着我输入
C:\mysql\bin>mysql
按理来说应该提示我输入管理员用户名和密码才对,但没有,直接出来Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 8 to server version: 3.23.21-beta-debug
Type 'help' for help.
我安装程序的时候我不知道我的管理员用户名和密码,我不知道怎么改管理员用户名和密码,如果不改,我现在的管理员用户名和密码是什么呢?请大家帮忙,谢谢了!
+-----------+
输入mysql进行登陆!
接着我输入
C:\mysql\bin>mysql
按理来说应该提示我输入管理员用户名和密码才对,但没有,直接出来Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 8 to server version: 3.23.21-beta-debug
Type 'help' for help.
我安装程序的时候我不知道我的管理员用户名和密码,我不知道怎么改管理员用户名和密码,如果不改,我现在的管理员用户名和密码是什么呢?请大家帮忙,谢谢了!
比如我想把linux的数据库备份到/home/beinan,数据库的文件名为linuxsir031130.sql,所以应该输入如下的命令。
[root@linuxsir01 root]#/opt/mysql/bin/mysqldump -uroot -p linux > /home/beinan/linuxsir031130.sql
Enter password:在这里输入数据库管理员root的数据库密码
[root@linuxsir01 root]# /opt/mysql/bin/mysql -uroot -p linux < /home/beinan/linuxsir031130.sql
Enter password:在这里输入密码
如果机器好,数据库比较小,几分钟就好了。
6]其它一些比较常用的mysql指令;
查看状态
mysql> show status;
查看进程
源码:
mysql> show processlist;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+------+---------+------+-------+------------------+
| 16 | root | localhost | NULL | Query | 0 | NULL | show processlist |
+----+------+-----------+------+---------+------+-------+------------------+
1 row in set (0.00 sec)
mysql>
查看表,应该先指定一个数据库为当前数据库;比如是名为linux的数据库;
mysql>use linux;
mysql> show tables;
Empty set (0.00 sec)
改变管理员密码很简单,一条命令就可以搞定:
mysql -u root mysql
使用root用户登录到mysql数据库,注意是mysql这个数据:
然后查询一下你现在有几个用户:
select host, user from user;
仔细看看:
先删除掉test用户
delete from user where user='test';
然后删除掉不是本机的用户,以防不测:
delete from user where host != 'localhost';
刷新权限表:
flush privileges;
再次看一下是不是已经只剩一个root用户了:
select host, user from user;
而且host栏是localhost
好了,然后设置root的密码:
set password for root@localhost = PASSWORD(‘你的密码');
注意一定要使用password这个函数来加密你的密码,要不然会登录不上去的。
大功告成了,基本你的mysql现在已经比较安全了,但是要注意以后的问题。
祝好运。