INSTALL MYSQL ON CENTOS 6 WITH REMOTE ACCESS:-
rpm -qa | grep mysql
yum remove <ouput mysql label>
yum -y install epel-release; yum clean all
yum -y install mysql-server mysql pwgen supervisor bash-completion psmisc net-tools; yum clean all
rpm -qa | grep mysql
yum remove <ouput mysql label>
yum -y install epel-release; yum clean all
yum -y install mysql-server mysql pwgen supervisor bash-completion psmisc net-tools; yum clean all
#optional steps
mysql_install_db
chown -R mysql:mysql /var/lib/mysql
/usr/bin/mysqld_safe & sleep 10
mysqladmin -u root password jagdeep
#login to mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'jagdeep' WITH GRANT OPTION; FLUSH PRIVILEGES;
>>OR without login
mysql -uroot -pjagdeep -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'jagdeep' WITH GRANT OPTION; FLUSH PRIVILEGES;
#Update password:-
mysql -u root -p
mysql> use mysql;
mysql> update user set password=PASSWORD("JAGDEEP") where User='root';
mysql> flush privileges;
mysql> quit
/etc/init.d/mysqld restart
#execute mysql db script after login in to mysql
>> source /home/jagdeep/test.sql;
#HERE ADDING PORT IN FIREWALL
>>vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
# No need to add rule for output because in output accepting all
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
>>/etc/init.d/iptables restart
##IF YOU DON'T WANT TO ADD RULE IN FIREWALL THEN YOU NEED TO STOP IPTABLES
>>/etc/init.d/iptables stop
[mysqld]
datadir=/var/lib/mysqld
socket=/var/lib/mysql/mysql.sock
user=root
symbolic-links=0
lower_case_table_names=1
bind-address=0.0.0.0
Note:- lower_case_table_names is used for case insensitive.
#Mysql Admin command:-
/usr/bin/mysqladmin -u root password 'new-password'
mysqladmin -uroot -pjagdeep variables
mysqladmin -uroot -pjagdeep version variables
Note:- By using "mysqladmin -uroot -pjagdeep variables" this command we can see default variable values. If we want to override it, it can be done by my.cnf file.
mysql_install_db
chown -R mysql:mysql /var/lib/mysql
/usr/bin/mysqld_safe & sleep 10
mysqladmin -u root password jagdeep
#login to mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'jagdeep' WITH GRANT OPTION; FLUSH PRIVILEGES;
>>OR without login
mysql -uroot -pjagdeep -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'jagdeep' WITH GRANT OPTION; FLUSH PRIVILEGES;
#Update password:-
mysql -u root -p
mysql> use mysql;
mysql> update user set password=PASSWORD("JAGDEEP") where User='root';
mysql> flush privileges;
mysql> quit
/etc/init.d/mysqld restart
#execute mysql db script after login in to mysql
>> source /home/jagdeep/test.sql;
#HERE ADDING PORT IN FIREWALL
>>vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
# No need to add rule for output because in output accepting all
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
>>/etc/init.d/iptables restart
##IF YOU DON'T WANT TO ADD RULE IN FIREWALL THEN YOU NEED TO STOP IPTABLES
>>/etc/init.d/iptables stop
[mysqld]
datadir=/var/lib/mysqld
socket=/var/lib/mysql/mysql.sock
user=root
symbolic-links=0
lower_case_table_names=1
bind-address=0.0.0.0
Note:- lower_case_table_names is used for case insensitive.
#Mysql Admin command:-
/usr/bin/mysqladmin -u root password 'new-password'
mysqladmin -uroot -pjagdeep variables
mysqladmin -uroot -pjagdeep version variables
Note:- By using "mysqladmin -uroot -pjagdeep variables" this command we can see default variable values. If we want to override it, it can be done by my.cnf file.