How to connect to a MySQL database

Setup to connect locally
create user [email protected] identified by ‘secret password’;
create database thor character set utf8;
grant all on thor.* to [email protected];

select User,Host from mysql.user;

Setup to connect remotely
mysql> GRANT ALL ON fooDatabase.* TO [email protected]’′ IDENTIFIED BY ‘my_password’;

This statement will grant ALL permissions to the newly created user fooUser with a password of ‘my_password’ when they connect from the IP address

Testing Remotely
Now you can test your connection remotely. You can access your MySQL server from another Linux server:

# mysql -u fooUser -p -h
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.0.45 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> _

Leave a Reply

Your email address will not be published. Required fields are marked *