Tuesday, June 14, 2016

MySQL Short Notes


Connect to a MySQL server instance

mysql connect to remote sql servermysql -h 192.168.94.80 --port 3306 -u username -p

Granting a remote user access to a mysql dbms

log into mysql as root user and enter the following command
GRANT ALL ON *.* TO bar@'192.168.1.10' IDENTIFIED BY 'PASSWORD';

here grant all means granting SELECT, INSERT, UPDATE, and DELETE to a particular user.

Now by having *.* means that we have selected all the databases

bar is the username of the remote user

'192.168.1.10' = is the ip address of the remote user's computer

IDENTIFIED BY 'PASSWORD' = sets the password

Add sql db script to mysql mysql --user=username --password=password < sqlfile

Log all queries that mysql server executes

1.) Open my.ini file

2.) Locate [mysqld] and below that enter the following line

log=log.txt

3.) Restart mysql server

Now the log.txt will be created inside the mysql data folder.

Eg:- “C:\Program Files\MySQL\MySQL Server 5.0\data\log.txt"

Restart mysql server on windows

Open command prompt and enter the following commands
net stop mysql net start mysql

Find out what port MySQL is using / Change port mysql is using

Sometimes you forget the port mysql is running on.

Solution :-

1.) Open my.ini file

2.) locate [mysqld]
# The TCP/IP Port the MySQL Server will listen on port=3306

You can change the port mysql listens to my by assigning a new value to port. After that make sure to restart mysql server.

No comments:

Post a Comment