I am facing this error every time I create a database in CLI interface of mysql:
I am using Xampp
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
more reference Reference
A simple and 100% working solution for this problem is:
Install Xampp outside the C: Folder and it will definitely work for you, without any permission problems ever.
But remember to provide xampp-control.exe administrative privileges always to terminate any port problems.
Related
I feel like I've tried everything.
user root with empty password doesn't work.
Tried uninstalling and reinstalling mysql. Doesn't work.
Thinking this had something to do with my project in Laravel, I uninstalled and reinstalled it. Started a fresh project. Nope.
Uninstalled reinstalled Homestead. Nope.
Uninstalled reinstalled Vagrant. Nope.
My database config in Laravel looks like this:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
But when I try:
mysql -u homestead -p
and 'secret'
I get:
ERROR 1045 (28000): Access denied for user 'homestead'#'localhost' (using password: YES)
I followed all the steps to this post, and....can you guess? NOPE NOTHING.
Access denied for user 'homestead'#'localhost' (using password: YES) on Laravel 5.2.27
Please help. I will be happy to provide any more information if I missed anything.
I had an old version of Homestead.yaml laying around I think. All I had to do was to change mysql to true under features in my Homestead.yaml. This was false for some reason.
Then i did
vagrant destroy
vagrant up
And everything was working. Hopefully this helps someone
I've ran into this before and honestly sometimes it differs from one person to another, so here is a couple of solutions I know:
First:
Add a password to mysql by running mysqladmin -u root -p pass
But I believe you already tried that so on to the next one,
Second
use this query inside the mysql cli:
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('root');
Please notice that this method directly manipulates your database, you just have to start your mysql cli inside your vagrant vm, and type that query as it is inside, then try to login with root as the username and root as password, hopefully this helps.
You can try reseting the root password by running MySQL in Safe Mode.
Stop MySQL:
sudo /usr/local/mysql/support-files/mysql.server stop
Start it in safe mode:
sudo mysqld_safe --skip-grant-tables
This will be an ongoing command until the process is finished so open another shell/terminal window, and..
Log in without a password as root:
mysql -u root
Update root (and any other user's) password)
FLUSH PRIVILEGES;
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
\q
Restart MySQL in normal mode
sudo /usr/local/mysql/support-files/mysql.server start
Reference: https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/
Note: this is pretty much a copy-paste from the reference link. this is pretty standard reset procedure, but just documented better in that guide compared to mysql reference docs.
I am new to MySQL. I have installed MySQL 5.6 in Windows 7 with user root and given password to it. But when I start MySQL Workbench and try to connect database, I am getting an error.
My try:
Connect to Database:
Connect to MySQL Server:
Error:
Then I tried to reset password with command prompt:
Please help me, I am new to MySQL, not getting what to do.
Thanks
It's possible that your setup is not listening for IP connections and is only listening on a local socket. Try:
mysql -u root
If you have already set a root password, try:
mysql -u root -p
on the command prompt. Or try removing the hostname from workbench.
You can resolve this issue using these steps.
1.open the terminal
2.exectute the command - sudo mysql -u root
3.then,execute - ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';(*replace the "new_password" with your new password"
4.exit;
5.now check the connection...It will work :)
It seems you do not have access for such task, exit the application and re-start it as administrator . Run As Administrator
I've just installed xampp, and am using command line to write mySQL.
I am using 'root' with no password and can connect to mysql but cannot CREATE DATABASE as I get the error 1044 access denied for user '' # 'localhost'. I am logged in as -uroot.
I have privileges in phpMyadmin to do what I want, but, in command line I seem to have no write privileges. I've looked at all the other related posts on this topic but to no avail. I cannot GRANT privileges as I have none anyway.
Are you logging into MySQL as root? You have to explicitly grant privileges to your "regular" MySQL user account while logged in as MySQL root.
First set up a root account for your MySQL database.
In the terminal type:
mysqladmin -u root password 'password'
To log into MySQL, use this:
mysql -u root -p
To set the privileges manually start the server with the skip-grant-tables option, open mysql client and manually update the mysql.user table and/or the mysql.db tables. This can be a tedious task though so if what you need is an account with all privs I would do the following.
Start the server with the skip-grant-tables option
Start mysql client (without a username/password)
Issue the command
flush privileges;
which forces the grant tables to be loaded.
Create a new account with the GRANT command something like this (but replacing username and password with whatever you want to use.
GRANT ALL on *.* to 'username'#'localhost' identified by 'password';
Restart the server in normal mode (without skip-grant-tables) and log in with your newly created account.
Refer this MySQL docs.
navigate do C:\xampp\mysql\bin\ and make sure the file mysql.exe is in that folder.
mysql -uroot -p
if dont have a password just press enter.
the prompt changes to
mysql>
do your mysql commands
By default there is no password is set for root user in XAMPP.
You can set password for root user of MySQL.
Navigate to
localhost:80/security/index.php
and set password for root user.
Note:Please change the port number in above url if your Apache in on different port.
Open XAMPP control panel Click "Shell" button
Command prompt window will open now in that window type
mysql -u root -p;
It will ask for password type the password which you have set for root user.
There you go ur logged in as root user :D Now do what u want to do :P
Gain access to a MariaDB 10 database server
After stopping the database server, the next step is to gain access to the server through a backdoor by starting the database server and skipping networking and permission tables. This can be done by running the commands below.
sudo mysqld_safe --skip-grant-tables --skip-networking &
Reset MariaDB root Password
Now that the database server is started in safe mode, run the commands below to logon as root without password prompt. To do that, run the commands below
sudo mysql -u root
Then run the commands below to use the mysql database.
use mysql;
Finally, run the commands below to reset the root password.
update user set password=PASSWORD("new_password_here") where User='root';
Replace new_password _here with the new password you want to create for the root account, then press Enter.
After that, run the commands below to update the permissions and save your changes to disk.
flush privileges;
Exit (CTRL + D) and you’re done.
Next start MariaDB normally and test the new password you just created.
sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
Logon to the database by running the commands below.
sudo mysql -u root -p
source: https://websiteforstudents.com/reset-mariadb-root-password-ubuntu-17-04-17-10/
I had the same issue, and it turned out to be that MariaDB was set to allow only root to log in locally via the unix_socket plug-in, so clearing that setting allowed successfully logging in with the user specified on the command line, provided a correct password is entered, of course.
See this answer on Ask Ubuntu
I re-installed the ODBC connector msi and re-installed mySQL directly (aside from xampp) and it now works. It was a connector problem I think, as SHOW DATABASES wasn't actually showing my databases at all.
My 'root' login wasn't getting access to the DB, which made it seem like it had limited priviliges but it actually wasn't connected properly.
Server file only change name folder
etc/mysql
rename
mysql-
this might help on Ubuntu:
go to /etc/mysql/my.cnf and comment this line:
bind-address = 127.0.0.1
Hope this helps someone, I've been searching for this a while too
Cheers
You mustn't have a space character between -u and the username:
mysql -uroot -p
# or
mysql --user=root --password
I've installed mysql5 using Macports and the installation appears to check out but I cannot login to the server at all.
This is what I did:
sudo port install mysql5-server
This builds and installs fine.
sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql
This runs fine as well. It outputs the following:
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h LeoMacBook.local password 'new-password'
Alternatively you can run:
/opt/local/lib/mysql5/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!
Now...let's follow the instructions exactly. I start the server:
sudo /opt/local/lib/mysql5/bin/mysqld_safe &
Server is running fine.
When I try to change the root password, I CANNOT log in.
LeoMacBook:bin leonardteo$ /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost' (using password: NO)'
I'm at wits end.
I've started the server with --skip-grant-tables. With this, I can load up mysql fine from the command line and I'm connected to the server. When I run SELECT * FROM mysql.user;, it returns an empty set! With this, I've tried to create a new user by invoking the command:
CREATE USER 'root'#'localhost' IDENTIFIED BY 'root';
But this doesn't work. I get the error:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
I cannot get this working. It seems I am so close, yet the root user seems to be missing.
Any ideas?
Leonard
Once you've started up mysql with --skip-grant-tables, issue a flush privileges; query. This'll re-enable the permissions system and allow you to run the usual grant and create user queries.
I'm working through tutorials in the book 'Cloning internet apps w/ Ruby.' I've made web apps before but they depended on sqlite and now I have to use mysql.
I've installed community server but when I try to create a database using the command line I'm receiving the error message listed above.
$ mysql
mysql> create database tinyclone;
Returns
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'p'
Notes:
The mysql command-line client flashes open and immediately closes, so I'm accessing it from the command prompt.
I've installed and uninstalled mysql several times in attempts to figure out this problem. In the latest install, I didn't set a password.
I'm aware that this line should probably be '$mysql -u <username> -p <password>' but I didn't set a password and I'm not sure what the username would be.
By default, the user is root
If you havn't set a password, use $ mysql -u root
The default MySQL username is 'root', try that without a password
The default username for MySQL is root, so you can try by
$ mysql -u root
by default it logs you with your Linux account. If you're logged as root on your Linux machine it will be OK just using $ mysql