Login to mysql with your usernamse and password.
eg: mysql u root -proot
Then execute the following command:
SELECT table_schema "DB Name", ROUND(SUM(data_length + index_length)/1024/1024, 2) "Size in MBs"
FROM information_schema.tables
GROUP BY table_schema;
Here SUM(data_length + index_length) is in bytes. Hence we have divided it twice by 1024 to convert to Megabytes.
By default, access to mysql databases is bounded to the server which is running mysql itself. Hence, if we need to log-in to the mysql console or need to use a database from a remote server, we need to enable those configs.
Open /etc/mysql/my.cnf file.
sudo vim /etc/mysql/my.cnf
Then uncomment "
bind-address = 127.0.0.1"
*Note: if you cannot find bind-address in the my.cnf file, it can be found in /etc/mysql/mysql.conf.d/mysqld.cnf file.
Restart mysql using:
service mysql restart;
This will allow login in to mysql server form a remote machine. To test this, go to the remote server, and execute the following.
mysql -u root -p -h <ip_of_the_sever_running_mysql>
This will open up the mysql console of the remote sql server.
But this will only allow to login in to the mysql server. But here we want to use/access the databses from (a client app in) our remote machine. To enable access to databases, we need to grant access for each database.
grant all on *.* to <your_username>@<ip_of_server_uses_to_connect> identified by '<your_password>';
If you want to allow any ip address to connect to the database, use '%' instead of
<ip_of_server_uses_to_connect>.