I was working on a MySQL Fabric installation, and had been working with disable_authentication set to yes:
...
[protocol.xmlrpc]
address = 0.0.0.0:32274
threads = 5
user = admin
password = hunter2
disable_authentication = yes
realm = MySQL Fabric
ssl_ca =
ssl_cert =
ssl_key =
...
I set it to 'no', and ran mysqlfabric manage stop then mysqlfabric manage start --daemonize. The client app broke, so I set disable_authentication back to 'yes' and ran mysqlfabric stop again to restart it, but I got:
Permission denied.
I looked through the documentation, both locally and at online, and haven't seen any way to pass a username and password to the mysqlfabric utility. I tried -u -p as in MySQL and --user and --password, to no avail. The latter gives
mysqlfabric: error: no such option: --password
Which seems to suggest that --user is a valid option, but I tried --pass and -p with no success.
I could probably just kill the process, but I'd like to know how to cleanly restart the server when authentication is enabled.
After plumbing around in the code for mysqlfabric, I noticed that it looked like the mysqlfabric utility was re-reading the newly-modified config file, seeing that disable_authentication was now set to 'yes', and thus clearing out any credentials, even if I specified them on the command line.
As far as I can tell, the running mysqlfabric instance still had credentials enabled, so when it was presented with the cleared-out credentials, it denied permission.
The solution was to change the config file back to disable_authentication = no, stop the server, then edit the config file to disable authentication, and start back up.
Takeway lesson:
Don't modify the Fabric configuration file while it's running, make sure to stop the server, edit the config, and then start it back up.
While I was at it, it seems that if you do need to specify a username/password, the command is indeed:
mysqlfabric manage stop --user=<username>
It will then prompt for a password.
Related
I am looking at automating a couple things when installing MySQL to a new host using a Chef server. These include:
mysqladmin -u root password {password_here}
mysql_secure_installation
I've created a .mylogin.cnf file with two login-paths, admin (which is root user), and mysqluser (non root user).
My issues are that I can't get (or understand how) .mylogin.cnf to create the DB users and password; and I can't automate the mysql_secure_installation using --defaults-file=.mylogin.cnf (assuming that's how the --defaults-file works) even though it's not specifying a login-path. Initially I was running the mysql queries via command line to harden the service, but was told that mysql_secure_installation uses --no-defaults, and --defaults-file to automate this particular task, but haven't found much online about those arguments.
Can anyone point me in the right direction?
The option --defaults-file is NOT used for setting/changing options in whichever tool you are running. This file is only used for specifying connection options (ie: host, username, socket, etc). For mysql_secure_installation specifically, you might try --use-default which, according to the manual, is used for unattended execution. In MySQL 5.7, a random root password is generated and printed in the error log. Simply grep this file for that password in your Chef script, then connect to MySQL and run whatever commands you need to create new users, dbs, etc. FYI, the generated root password is expired so when you connect, you have to change it first before you can do anything else.
I'm trying to login to my mysql user created by the MySQL installation in bash shell.
So the command I'm trying to do is:
sudo -i -u mysql
But, it does nothing (nothing printed out in the console, not connected to any user whatsoever, etc...).
EDIT: The return value of the command is 1 though.
Here is the mysql user line in the /etc/passwd file:
mysql:x:89:89::/var/lib/mysql:/bin/false
I'm running on ArchLinux 64bit and the user I'm trying to connect to is local (no connection to a remote server whatsoever).
I'm trying to understand why I can login with any other user (like postgres, root, ...) but not mysql.
Hope you can help!
This is intended behaviour. When you compare the /etc/passwd line with other lines you'll notice that the user mysql has /bin/false setup as the shell while others have usually /bin/sh or sth. similar.
When you sudo to mysql you actually get a login for about a millisecond or so and then his "shell" gets executed. /bin/false immediately returns with rc=1 (that's the only purpose of the false command).
This is some kind of "trick" to prevent users from logging in as user mysql although the account is otherwise fully operational.
The user mysql may even have a valid password and be enabled but due to his odd shell setting you cannot login as him. Sometimes these technical users have /usr/bin/passwd set as their shell. Then you can only sudo to that user and change his password, nothing else.
I know there are many mysql-proxy questions on SO, however I have read through many of them and none seem to solve my problem. I am simply trying to get mysql-proxy up and running, with the eventual purpose of rewriting some queries that go through the proxy. I am using ubuntu 14.04, I have mysql-proxy version 0.8.1, and mysql version 5.5.37. To start mysql-proxy I run the following line on the command line
sudo mysql-proxy --defaults-file=mysql-proxy.cnf
where the file mysql-proxy.cnf looks like the following:
[mysql-proxy]
log-file= /var/log/mysql/proxy-error.log
log-level= debug
admin-lua-script= /usr/lib/mysql-proxy/lua/admin.lua
proxy-lua-script= /path/to/lua/script/example.lua
admin-username = myusername
admin-password = mypassword
proxy-skip-profiling = true
proxy-address = localhost:4040
proxy-backend-addresses = localhost:3306
plugins = proxy,admin
My example.lua script is very simple, and meant only to verify that the mysql-proxy query is being altered. example.lua is pasted below
-- first_example.lua
function read_query(packet)
if string.byte(packet) == proxy.COM_QUERY then
print("Hello world! Seen the query: " .. string.sub(packet, 2))
end
end
Since I don't run this with the --daemon flag, when I run that line above in the command line it just loops indefinitely, which is expected.
Finally, in separate terminal session, I run the following on the command line and enter my password in order to connect with the proxy
mysql -u myusername -p -h localhost -P 4040
I then select a database to use, and run a simple SELECT query on one of the tables. Based on multiple articles/tutorials I've read on mysql-proxy, my first console session, the one that ran mysql-proxy, should print out some data based on the example.lua file. However this does not happen, in fact nothing happens.
I'm not sure if the following bit of information makes any difference, but in my "my.cnf" mysql configuration file, I have these couple of lines
bind-address = 255.255.255.255
#bind-address = 127.0.0.1
where I have replaced my actual ip address with 255.255.255.255 because I do not want to display my ip address publicly.
Please, I have been trying to figure this out for several days, and no amount of new lua scripts, or changing the host:port parameters in the mysql-proxy.cnf file have solved anything. I
I am working on a windows server 2012 and trying to get PHPMyAdmin working. I cant get it to connect to the MySQL by root user or a non root user. I have searched and searched all over google. everywhere I saw it said to set allowroot and change localhost to 127.0.0.1 in the config.inc.php file. At first I could not find this file but then I read you have to change config.default.php to it and put it in the root folder. I did that. and here is what I changed
$cfg['Servers'][$i]['host'] = "127.0.0.1"
//already had the next one set
$cfg['Servers'][$i]['AllowRoot'] = true
I still cant get it to login from any user on MySQL, and I keep getting the error
#2002 Cannot log in to the MySQL server.
config.inc.php: http://u16626886.onlinehome-server.com/config.inc.zip
Testing PHP and MySQL: http://u16626886.onlinehome-server.com:801/test.php
I figured out the problem just need to solve it now. If I put MySQL on the C: drive it works fine but if I put it on the D: drive, which is where I want it, PHP can not connect to it. Does anyone know why that is?
It may be Mysql service is not running, try to start Mysql service
Sometimes Mysql Service May Not Run..
Try the following
1. Remove/Unstall the service
a) Start Cmd As Administrator
b) Type Mysql --remove
2. Restart Pc
3. Install
a) Start Cmd As Administrator
b) Use Cd ../ To locate the path for Mysqld (For me it is in C:\xampp\mysql\bin)
c)Type mysqld --Install
4. Restart Pc
This is a 2002 MySQL Socket error, we can resolve this quickly by executing following command
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Note: Above path is based on MAC, so you can change the path according to your OS
This was solved my problem on mac.
-config.inc.php-
change
$cfg['Servers'][$i]['AllowNoPassword'] = false;
to
$cfg['Servers'][$i]['AllowNoPassword'] = true;
and then,
-go to terminal -
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
and then come back and reloaded page.
Run SKYPE then using the menus do this:
Tools -> Options -> Advanced -> Connection
Un-Check the checkbox next to 'Use port 80 and 443 as alternatives for incomming connections'
Now restart SKYPE for these changes to take effect.
I accidentally changed the "host" value for the root user inside of the user table for mysql.
I need to change it back to localhost because I changed it to arancillary2125 (my other machines DNS name) but I cannot access mysql (from PHPMYADMIN or command prompt) due to "localhost" not having permissions any more.
I am running windows XP // apache //
I have tried the following solutions but they didn't work:
https://serverfault.com/questions/92870/1130-host-localhost-is-not-allowed-to-connect-to-this-mysql-server
Whoops.
This is on your local machine, I assume? At Start->Run, enter 'services.msc' and locate the MySQL service. Stop the service.
Edit:
Find your my.ini file (usually in C:\Windows or C:\mysql, etc). If you don't have one, create one. It's just a plain ASCII file.
Alter the file, add this in the [mysqld] section: skip-grant-tables.
On the command line, issue the command net start MySQL and wait a moment, the MySQL service should start.
Still on the command line, issue the command mysql -u root and hit "ENTER". You should be logged into MySQL as the 'root' user. Carefully change your grants and then logout. Stop the MySQL service / server. Re-edit your my.ini file and remove / comment out the skip-grant-tables line, and again start the server. Try to login as root again.
Just tested this on my Win XP Pro box.
This essentially has the effect of bypassing all the grant tables and thus doesn't bother to lookup whether you're supposed to access it from that machine or not.
MySQL reference manual : --skip-grant-tables option
So I had this problem aswell, happened all of a sudden with #1130 - Host ‘localhost’ is not allowed to connect to this MySQL server.
After searching and searching I can tell you that bdl solution is the way forward, once you can log back into the server you can change the permissions about and remove the line skip-grant-tables under your my.ini mysql config file.
I would have just upvoted bdl's post but im too new on the website to do that yet.
Recreate arancillary2125 (if even on an old desk top) and then access your DB that way.