1、查看数据库占用容量:
use information_schema;
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES;
2、开启root远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH privileges;
3、重置root用户密码
首先,我们停掉MySQL服务:
sudo service mysql stop
[root@localhost ~]# service stop mysql
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
[root@localhost ~]# service mysql stop
Shutting down MySQL.. [ OK ]
以安全模式启动MySQL:
sudo mysqld_safe --skip-grant-tables --skip-networking & mysql -u root
接着重设密码:
mysql> use mysql;
mysql> update user set password=PASSWORD("mynewpassword") where User='root';
mysql> flush privileges;
重设完毕后,我们退出,然后启动 MySQL 服务:
mysql > quit
重启服务:
sudo service mysql restart