Resolving Bitnami MySQL Connectivity Issues - mysql

I have setup Bitnami MySQL service on Azure. The VM is up and I am able to connect to the VM through ssh
like ssh username#HOSTNAME:
I am able to login to the mysql from the prompt like
mysql -uroot -pSOMEPASS
>
Meanwhile I am able to connect this mysql service from a remote host:
mysql -uroot -pPASS -hxxx.xxx.xx.xx
The following error is what I received
ERROr 2003 (HY000); Can't connect to MySQL Server on xxx.xxx.xx.xx
I tried commenting out the the bind-address in the /opt/bitnami/mysql/my.cnf
and tried giving the value for bind-address as 0:0:0:0 & also removing the variable.
To ensure the mysql port is up or not I gave the following comamnd
netstat -tln
tcp6 0 0 :::3306 :::* LISTEN
the above results mean port is and listening
In terms of file permission related, I entered the following ones
chmod 777 /opt/bitnami/mysql/tmp
chmod 755 /opt/bitnami/mysql/data
chown -R root:root /opt/bitnami/mysq/tmp
chown mysql:root /opt/bitnami/mysql/data/
sudo chmod 777 /opt/bitnami/mysql/tmp
sudo chmod 755 /opt/bitnami/mysql/data
sudo chown root:root /opt/bitnami/mysql/tmp
sudo chown mysql:root /opt/bitnami/mysql/data
Also added
skip-grant-tables in my.cnf
I also performed the following the query in the mysql
GRANT ALL ON . to root#'%' IDENTIFIED BY 'SOMEPASSWORD';
Any hint would be greatly appreciated. Thanks in advance

To connect to your Bitnami MySQL, follow these steps:
1.Make sure your Azure VM have a public IP address.
2.Open port 3306 to NSG inbound rules:
3.Edit the file /opt/bitnami/mysql/my.cnf and comment out this line by placing a hash(#) symbol at the beginning, save it.
#bind-address=127.0.0.1
4.At the server console, allow remote access to the MySQL database server using the MySQL command line client. Use the following command, remembering to replace PASSWORD with the application password from the first step:
/opt/bitnami/mysql/bin/mysql -u root -p -e "grant all privileges on *.* to 'root'#'%' identified by 'PASSWORD' with grant option";
5.Restart the MySQL server:
sudo /opt/bitnami/ctlscript.sh restart mysql
Now, you can remote connect to your bitnami mysql.
Here is my result:
Hope this helps.

Related

MySQL remote access on Ubuntu 16.0.4

The followings are commands which I have executed on Ubuntu.
$ mysql -u root -p
mysql>GRANT ALL ON my_database.* TO user#'MY_REAL_IP' IDENTIFIED BY 'passwd';
$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
#bind-address = 127.0.0.1
$ sudo ufw enable
$ sudo ufw allow 3306
$ service mysql restart
But when I use another computer on Ubuntu to access mysql on MY_REAL_IP type:
$ mysql -u user -p -h MY_REAL_IP
Can't connect to MySQL server on 'MY_REAL_IP'
how to fix it? thx
I guess bind-address should be 0.0.0.0. If you would like to access this server with real IP address. Or, you can access MySQL with simply localhost.
Would you please change bind-address = 0.0.0.0, and restart MySQL ?
EDIT
It looks there is no network connectivity. Please find the way to connect server with port 3306. How to make sure that firewall is off?
You may misunderstand the grand command, user#host means the user can login from host, which in your case, should be another computer's ip, or just use * for all ips
Exact path on Ubuntu 16.04
/etc/mysql/mysql.conf.d/my.cnf
bind-address = 0.0.0.0
service mysql restart

mysql not connect from remove pc installed on Amazon EC2

I have just created one instance on Amazon EC2 for CentOs, and installed mysql on it with root user (password is blank). Then I had created another user for me to connect this instance from remote pc (my local pc). for that I had run following command on terminal one by one.
CREATE USER 'demouser'#'%' IDENTIFIED BY 'demopassword';
GRANT ALL PRIVILEGES ON *.* to 'demouser'#'%';
FLUSH PRIVILEGES;
Then I wrote following line in /etc/my.cnf under [mysqld] section
bind-address=0.0.0.0
Then restarted mysql with following command
sudo /sbin/service mysqld restart
Still, It is not allowed to connect that instance from my local pc. I don't understand what is the problem? I had checked and confirmed that rules on Amazon Security Groups are set properly. (e.g. port 3306 & 22 set to 0.0.0.0 ip address, means any ip address can connect using both ports).
Can someone saw me the mistake of mine?
Slowed
I ran following command to update ipaddress in centos terminal;
sudo iptables -I INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
and It's getting connected... !!!!

cannot access mysql database remotely on ubuntu

Here are the steps I followed for accessing the database remotely:
For machine A
sudo apt-get install mysql-server
sudo mysql_install_db
set bind_address=0.0.0.0 on path /etc/mysql/my.cnf
started mysql database on machine A
mysql -u root -p
created a user using following command
create user 'techrocks'#'%' identified by 'myass';
grant all privileges on *.* to 'techrocks'#'%';
flush privileges;
exit mysql and restart mysql, then sudo /etc/init.d/mysql restart
ON machine B I installed mysql-server and then tried to access mysql of machine A
mysql -u techrocks -h ip-address-of-machine-A -p
mysql started but when I tried to create a database as
create database mydb1;
I got access denied error
Access denied for user 'teckrocks'#'%' to database 'mydb1'
Open my.cnf (/etc/mysql/my.cnf)
bind = IP of remote
then try to connect..

How to stop and start the mysql?

When I'm use the find command to locate the MySQL location, it returns the below paths. But, I want to restart the MySQL. If I stop the path (/usr/bin/mysql) it shows the error
[Access denied to user 'root'#'localhost' with password='NO]'
so, Which MySQL will be get restart in the below paths ?
/usr/bin/mysql
/usr/share/mysql
/usr/lib/mysql
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/mysql
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/DBD/mysql
/usr/lib64/mysql
/var/lib/mysql
/var/lib/mysql/mysql
to stop mysql account is:
sudo mysqladmin -h localhost -u root -p shutdown
to start is:
sudo systemctl start mysql.service
to confirm:
sudo mysql -h localhost -u root -p
NB:
the default password for root account is root
**not sure but i think this closes connection for all accounts & also starts for all accounts though you have stop using an account with privilege access/root access by using the grant statement.
example
GRANT ALL PRIVILEGES ON databasename.* TO 'username'#'localhost';
source http://www.luciopanasci.it/Ebooks/MySQL%20Cookbook,%203rd%20Edition.pdf
page 2 topic 1.1**
As root, run
service mysqld restart
If that does not work, try
/etc/init.d/mysqld restart
Instead of restart you can use :
start to start mysql
stop to stop it
Usually you do
/etc/init.d/mysql start/stop/restart
It may be called mysqld or mysql-server or something like that. If you're on Ubuntu, you have to do
service mysql start/stop/restart
there it may be mysqld or mysql-server or something like this as well.
If Mysql is running as a service:
sudo service mysql restart;
or
sudo service path/to/mysql restart;
Edit:
check if mysql is running
service --status-all
service --status-all | grep mysql
If Mysql is running, use
To Restart: service mysqld restart
Other command which can be used if necessary are given below.
To Stop: service mysqld stop
To Start: service mysqld start

Can't start mySQL

Even after I reset the root password with the following command I can not log to MySQL: (other commands listed to provide additional info)
# sudo dpkg-reconfigure mysql-server-5.1
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
# telnet 127.0.0.1 3306
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
# ps -Aw |grep mysql
26522 ? 00:00:00 mysqld
# /etc/init.d/mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
update:
# sudo mysqladmin -u root password 123
mysqladmin: connect to server at 'localhost' failed
it seems MySQL is not running properly
Update:
I am using MySQL 5.1 under Ubuntu.
It was OK until that I make some change in my.cnf to enable Remote Access. I undo my changes but problems did not solved! (Perhaps I forgot to undo some thing!)
update:
# service mysql status
mysql start/running, process 26650
# /etc/init.d/mysql status
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql status
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the status(8) utility, e.g. status mysql
mysql start/running, process 26650
to set root password:
mysqladmin -u root password NEWPASSWORD
To recover it:
http://www.cyberciti.biz/tips/recover-mysql-root-password.html
My best guess is that if you have reconfigured / reinstalled MySQL, you need to login without a password, e.g.:
mysql -u root
or even
mysql
Edit: To see if the service is running, you could try:
service mysqld status
and if it is not running, try:
service mysqld start then check the status again.
It seems like MySQL is definitely not running. You can verify this with /etc/init.d/mysqld status or service mysqld status (don't link directly to the service command).
My spidey sense is telling me either your O/S or MySQL installation were performed improperly. It would help tremendously to know more about the (linux?) environment you're running, and how it was configured (or who configured it, in the case of PaaS).
Start as a service
sudo service mysql restart
to verify & check the service and the port
sudo netstat -tap | grep mysql
you should change the access permission. it should be 0644
sudo chmod 644 /etc/mysql/my.cnf
and then
sudo dpkg-reconfigure mysql-server-5.5