I've never had a MySQL install go smoothly. Not Mac. Not Windows. And now Linux joins the mess.
I installed mysql-server via Software Manager after a failed attempt with linuxbrew. I can actually run it in terminal, but I have to use sudo which seems odd. I don't see any examples where the user has to use sudo.
On top of that, when I run MySQL Workbench I can't connect. I get the error, Access denied for user 'root'#'localhost'
Any suggestions?
Did you install mysql from apt-get install mysql-server ? it probably asked you for a default root password (Ubuntu like systems usually do). If you have forgotten it, have no fear, the password can be reset
http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html#resetting-permissions-unix
Try doing this as linux root (sudo -i), if that doesn't work try
sudo -i
sudo mysql
and give it a shot.
Alternatively, sudo, connect to mysql and create another user account with full privileges something like
GRANT ALL ON *.* to someother user identified by ...
You cannot connect remotely with root database user since the default user created doesn't have access on '%' (remote access).
Create another user with limited rights (secure) and use it for workbench.
creating user on mysql:
create user test#'%' identified by 'test_user_password';
grant all on *.* to test; -- you can specify specific permissions/databases
flush privileges;
Try these credentials with workbench.
As far as the linux command line is concerned
mysql -uroot -p
-- hit enter, no password and see if you can get connected
Related
I have tried to install mysql, and then to run with
mysql -u root -p
but I get
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
I can get in with sudo, but I don't want to run as root. How do I get to run mysql as non-root?
I am using Linux Mint 19.1 32-bit.
What I tried:
sudo apt-get install mysql-client
sudo apt-get install mysql-server
sudo /etc/init.d/mysql restart
sudo mysql_secure_installation
Set up VALIDATE PASSWORD? No
Remove anonymous users? No
Disallow root login remotely? Yes
Remove test database and access to it? No
Reload privilege tables now? Yes
Then I try
mysql -u root -p
it asks for the password, I give the same one I gave in mysql_secure_installation...
frank#frank-laptop:~/WebDev$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
Gah.
I have reinstalled mysql client and server several times now, doing a complete uninstall between and getting rid of all databases when asked. I don't get asked for a root password during the install. That seems to be normal for an install in Ubuntu and derivatives, hence the mysql_secure_installation to set the password.
I tried following
http://www.yolinux.com/TUTORIALS/LinuxTutorialMySQL.html
I tried searching on the web for hints, e.g.
https://askubuntu.com/questions/766900/mysql-doesnt-ask-for-root-password-when-installing#766908
and others but I have not been able to get mysql to start without sudo. If I do use sudo I can create a database, add tables and add data so the database is installed, I just need more privilege to run it than I think I should need.
Anywhere I looked, the instructions go from installation to starting mysql without anything special between, so I think I must be doing something quite stupid. But I have not been able to figure out what.
The first time you run mysql -u root -p , you have to run it with sudo in order to create a new user:
DROP USER 'root'#'localhost';
CREATE USER 'XXX'#'%' IDENTIFIED BY 'YYY';
GRANT ALL PRIVILEGES ON *.* TO 'XXX'#'%' WITH GRANT OPTION;
Then you can connect yourself using mysql --user=XXX --password=YYY
I already try but I don't think you can setup your DB without using sudo unfortunately.
I installed MySQL on Ubuntu 16.04. I can login to MySQL shell by typing the command:
sudo mysql -u root
However, I also want to see the DB via MySQL Workbench. I installed it on my computer, and when I go to Database -> Connect to Database I get the following window:
When I click 'OK' I get the following dialog:
I checked 1 and 2. 3 I don't know how to check and as for 4, I don't know what is the password at all (I don't have to use it to login via the console).
Do you know how to resolve it?
Firstly never work with root on a server. Period it is a bad habit. So first things first would be to log into the command line and create a user that is the root equivalent and then use that user.
So use the command line and then execute the following steps:
CREATE USER 'username'#'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'#'%'
WITH GRANT OPTION;
FLUSH PRIVILEGES;
This will create an administrative user called username. You can then use this account to log in. Get in the habit of doing this.
Use terminal login mysql
sudo mysql -u root
Initial root password
update user set password=PASSWORD(‘123456’) where User='root';
And then try workbench login again.
If you want to connect mysql service from any others host except localhost,
you need set root host to %
mysql -u root –p
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user; --check result,init value maybe 127.0.0.1 or localhost
I think that I found the problem. When I installed MySQL, I skipped the option to give a password to root user. Therefore, I decided to remove MySQL from my linux by using the command:
apt-get purge mysql mysql-server mysql-common mysql-client
and then re-install it by:
apt-get install mysql-server
This time, I gave a password to root user during the installation, and after the installation had been finished, I opened MySQL Workbench and used the password I gave during the installation.
I tried changing MySQL root password right after installing it. Now on terminal, it says to check out some newer query ALERT USER. I checked the documentation, but it's still the old query CHANGE PASSWORD
Any help please
Ok i found a way to change the root password from workbench i just clicked on "local instance 3306" in the home page and gave me a choice to change root password, it's even easier than changing it from the terminal !
instruction that worked with my case.
mysql -uroot -p (default root password is blank with brew install)
use mysql;
ALTER USER 'root'#'localhost' IDENTIFIED BY 'new_password';
That's it. ( Mac M1 MacBook, mysql installed with brew, mysql version 8.0.28 for macos12.0 on arm64 (Homebrew) )
If anyone has trouble with the mysql -u root -p command but know the current MySQL password and has MySQL Workbench installed, just try to start a command line client by right clicking your localhost connection in MySQL Workbench:
Once the command line client started, enter your current MySQL password when prompted in terminal. After that, use the ALTER USER 'root'#'localhost' IDENTIFIED BY 'new_password' command.
Using Mac M1 MacBook and mysql version 8.0.30
I am trying to install wordpress on Odroid C2.
However, wordpress could not access mysql.
So, I tried this.
If I execute mysql with sudo, it is OK. But, without sudo, I can't.
The OS of C2 is Ubuntu Mate 16.04, so I installed mariaDB instead of mysql.
I followed the guide of mariaDB installation.
How can I use mysql without sudo, and how can my wordpress access the DB.
try this to solve the problem:
Login in your DB
sudo mysql -u root -p
then make these modifications:
MariaDB []>use mysql;
MariaDB [mysql]>update user set plugin='' where User='root';
MariaDB [mysql]>flush privileges;
MariaDB [mysql]>exit
try login again without sudo
This should be an serverfault.com issues. But anyway, go through this checklist
Are you starting mysql with port other than 3306
Check access of mysql client is o+rx , i.e. ls -la /usr/bin/mysql
Did you grant user access other than "root" in mysqldb/mariadb. Mysql db may prevent you from using root#localhost if it is not running sudo
So if in case no 3, you must create a new user and grant access to it to solve this. i.e.
GRANT ALL ON <YOUR_WP_DATABASE_NAME>.* TO "wpuser"#"localhost" IDENTIFIED BY "somepassword";
Afterwards, try mysql using that user to confirm it works.
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