mysql常用操作
服务相关
[root@vm10-0-0-3 etc]# service mysql stop
Shutting down MySQL.... [ OK ]
[root@vm10-0-0-3 etc]# service mysql status
MySQL is not running [FAILED]
[root@vm10-0-0-3 etc]# service mysql start
Starting MySQL. [ OK ]
[root@vm10-0-0-3 etc]# service mysql restart
Shutting down MySQL.... [ OK ]
Starting MySQL. [ OK ]
重置密码
在my.cnf中添加
skip-grant-tables
重启mysql服务
[root@vm10-0-0-3 etc]# service mysql restart
Shutting down MySQL.... [ OK ]
Starting MySQL. [ OK ]
连接mysql服务
[root@vm10-0-0-3 etc]# mysql
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
修改root用户密码
mysql> update user set authentication_string=password('root') where user="root";
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
注释my.cnf中的skip-grant-tables
重启mysql服务