access denied mysql monitor - mysql

I installed xampp on 10.9 mavericks. Unfortunately the command mysql does not work in the terminal. I managed to start the mysql monitor from xamppfiles/bin/. When I try to create a new database I get
ERROR 1044 (42000): Access denied for user ''#'localhost' to database XY
What can I do?

No, you should run mysql -u root -p in bash, not at the MySQL command-line. If you are in mysql, you can exit by typing exit.
You may need to set up a root account for your MySQL database:
In the terminal type:
mysqladmin -u root password 'root password goes here'
And then to invoke the MySQL client:
mysql -h localhost -u root -p

Related

MySQL connection from command line, how can be a command line utility so unstable?

Since a few hours I'm trying to connect to a local sql environment. It works in one second with MySQL Workbench, but from the commandline MySQL is not very verbose :)
mysql -u root -p root --host=127.0.0.1 --port=10011 -password'root'
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Somewhere they report to use -u, while somewhere else they suggest --u
How do I find out if mysql is able to reach the server?
What else can I do for troubleshooting?
MySQL command line is a mess, the solution was
mysql -uroot -h127.0.0.1 --port=10011 -proot
Some with -- like port and some with - like p, and with no space.

mysql access denied for user ERROR 1045

I'm trying to user mysql on my machine, but I can't access the program.
I added configuration using mysql_config_editor as such:
mysql_config_editor set --login-path=client --user=root -p --host=localhost
and when i do a print i get:
[client]
user = root
password = *****
host = localhost
But when I try to connect to mysql, I get the following error
#mysql -u root -p
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using passowd: YES)
And when I try to connect like this, i get:
#mysql -u root -p -h127.0.0.1
ERROR 1130 (HY000): Host 'localhost' is not allowed to this MYSQL server
Every other answer I found was to do a SQL command. But i can't get inside the shell to do it.
Thanks
Have you already tried using the --skip-grant-tables option? If you have, and it doesn't allow you to access the mysql shell, go into your mysql installation folder and open my.ini file (my.cnf for most Linux distros). Inside it you'll find a mysqld tag, add skip-grant-tables underneath it and restart your mysql server. You'll be able to access your shell and therefrom edit the rights/privileges.

Show mysql databases as Linux root user

I'm logged into a CentOS server and I want to view all mysql databases. So I switched to the Linux root user and I tried logging into mysql. Normally (on other servers) I do this with a simple mysql command, but here I get an access denied:
[root#our.server.com kramer65]# mysql
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
I suppose that if I'm root on Linux I can do anything I want. Is there a way that I can show all Mysql databases as Linux root user?
From this you can log into your DB as linux root: if restarting servvices is an option:
https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password
sudo systemctl stop mysql
sudo mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root
Then the usual apply:
mysql>SHOW DATABASES;
The system root user is not the same as the root mysql user, and it's possible the system user has no access.
You can give the username to mysql with
mysql -u root -p
and enter the password for the mysql root user.
You can use the same command to connect with any mysql user account that is valid within mysql.

Installing snort, having trouble with SQL root password

So I am installing snort currently on my ubuntu linux server. I am following this guide here.
At this point, I am at the part in the guide where I am installing Barnyard2 and i need to access my SQL database to save information. linux server is near fresh install with little else on it. When I try to do this part of the guide:
echo "create database snort;" | mysql -u root -p
mysql -u root -p -D snort < ~/snort_src/barnyard2-master/schemas/create_mysql
echo "grant create, insert, select, delete, update on snort.* to \
snort#localhost identified by 'MYSQLSNORTPASSWORD'" | mysql -u root -p
When I run the first line - if I don't enter anything, I get the error message that says:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
If I do enter something, I get a different error:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I have tried using this in order to reset my password but the command mysql -u root or any form of command similiar results back in the same error, even when it says the password is probably not required for this command. Does anyone know a way in which I can get this to work?
Why don't you break that down into chunks?
First make the database:
$ mysql -u root -p -e 'CREATE DATABASE `snort`'
Import the barnyard schema
$ mysql -u root -p < ~/snort_src/barnyard2-master/schemas/create_mysql
Now create the user & assign permissions for the snort db to the barnyard user
$ mysql -u root -p -e 'GRANT CREATE, INSERT, SELECT, DELETE, UPDATE ON `snort`.* TO snort#localhost IDENTIFIED BY '[SNORT PASSSWORD]'
The commands in your question are running a local mysql client which assumes to connect to a local database by default. If your database is running on a neighbouring Windows box you will need to rethink your parameters.
mysql -u root -p -h 192.168.0.99

Unable to use database in mysql (unknown database)

I am trying to get started with the following github package: py-gameday.
I installed mysql with brew mysql and created a root password:
> mysqladmin -u root password 'xxx'
I then created a user:
> mysql -uroot -p
Enter password: xxx
CREATE USER 'josh'#'localhost' IDENTIFIED BY 'yyy';
and just in case, I reset the password again:
SET PASSWORD FOR 'josh'#'localhost' = PASSWORD('yyy');
and grant permissions:
GRANT ALL ON gameday.* TO 'josh'#'localhost';
and I then updated mydb.ini with:
[db]
user=josh
password=yyy
db=gameday
I finally tried running the following:
$ mysql -D gameday < gameday.sql -p
Enter password: yyy
ERROR 1049 (42000): Unknown database 'gameday'
Why doesn't it work? I have a gameday.sql sitting there on the directory.
You need to physically create the database in mysql. Currently the gameday.sql is just a set of commands to run in the mysql database which probably creates a bunch of tables.
You'll need to use CREATE DATABASE gameday; in mysql, then give josh permissions to write to that database. Then the mysql -D -p gameday < gameday.sql -p command should work.