Tag Archives: MySQL

Several MySQL commands used on command line

1) bin > mysql -h hostname -u user -p password databasename < filename or bin > mysql -h hostname -u user -p databasename < filename press “enter”, then it will show “>”, then input password.

2) mysql> CREATE DATABASE databasename;

3)
mysql> CREATE USER ‘username’@’localhost’ IDENTIFIED BY ‘password’;
mysql> GRANT ALL PRIVILEGES ON databasename.* TO ‘username’@’localhost’
-> WITH GRANT OPTION;
mysql> CREATE USER ‘username’@’%’ IDENTIFIED BY ‘password’;
mysql> GRANT ALL PRIVILEGES ON databasename.* TO ‘username’@’%’
-> WITH GRANT OPTION;

or GRANT ALL PRIVILEGES ON databasename.* TO ‘username’@’localhost’

Error:#2002 – No connection could be made because the target machine actively refused it.

Error:

#2002 – No connection could be made because the target machine actively refused it.
The server is not responding (or the local server’s socket is not correctly configured).
Connection for controluser as defined in your configuration failed.

I restart the Apache and MySQL, the problem disappears. Btw, port is 3306, don’t need to change to 80.