How do I change the default MySQL user on OpenSuSE 13.1 - mysql

How do I get the "mysql" command to open a connection to MySQL with the root user? I don't want to type mysql --user root, I want it to start immediately.
I have two machines: Mageia 3 and OpenSuSE 13.1. The Mageia machine does this exactly when I open a terminal as the normal user: it simply starts a mysql session and when I type SELECT USER(); it says "root#localhost".
The OpenSuSE machine tries to use the current bash user to connect to mysql instead of using root. How do I configure this behavior?

Specify a user option in the [client] section of ~/.my.cnf
...but generally its considered bad practice to use the admin account for normal use of a system.

Although symcbean's solution works, I found it easier to create a user with the same name as the Linux account that is calling the command. Give this user enough privileges and voilĂ . This way avoids the problem mentioned by symcbean.

Related

Sequel Pro and MySQL connection failed

I just installed mysql on mac from Homebrew
brew install mysql
mysql -V
mysql Ver 8.0.11 for osx10.13 on x86_64 (Homebrew)
from terminal it works and I can login to mysql but from Sequel Pro it says
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary
privileges, or try increasing the connection timeout (currently 10
seconds).
MySQL said: Authentication plugin 'caching_sha2_password' cannot be
loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2):
image not found
can't figure out what I am missing
This is because Sequel Pro is not ready yet for a new kind of user login, as the error states: there is no driver.
mysql + homebrew
Basically you will have to perform some actions manually, however- your database data won't be deleted like in solution below
Go to my.cnf file and in section [mysqld] add line:
default-authentication-plugin=mysql_native_password
Login to mysql server from terminal: run mysql -u root -p, then inside shell execute this command (replacing [password] with your actual password):
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY '[password]';
exit from mysql shell with exit and run brew services restart mysql.
Should work.
Quick fix (destructive method)
Quick fix for non-homebrew installs:
Apple Logo > System Preferences > MySQL > Initialize Database, then type your new password and select 'Use legacy password'
After restart you should be able to connect. Do it only on fresh installs, because you may lost your db tables otherwise.
my.cnf
The my.cnf file is located in /etc/my.cnf on Unix/Linux
Alternatives
For those who is still struggling with Sequel Pro problems: Sequel Pro was a great product, but with tons of unresolved issues and last release being dated to 2016 perhaps it's a good idea to look for some alternatives. There is a fork of SequelPro called SequelAce that seems to be pretty stable and up-to-date, it keeps similar functionality, similar look and feel, yet at the same time it is devoid of old Sequel Pro problems
TL;DR: Sequel Pro is dead since 2016. Don't downgrade your DB because of a tool. Move on to an alternative tool.
Update 2020: Sequel Pro is officially dead but unofficially alive! You can find the "nightly" builds that don't have this issue (i.e. support Mysql 8 auth) in here: https://sequelpro.com/test-builds
Update 2021: Sequel Ace is a good similar alive alternative: https://github.com/Sequel-Ace/Sequel-Ace#installation (Credits to Maciej Kwas's answer)
All the other solutions here are recommending changing your DB settings (making it less secure, as advertised by MySQL) for the tool you are using. That's not acceptable to me.
I have always been a huge fan of Sequel Pro, even donated to it. But, with all my passion and love, I am sorry if the tool doesn't have any release since 2016. YOLO, and I need to move on!
The alternative I found (from https://stackoverflow.com/a/55235533/2321594, thanks to #arcseldon) is DBeaver which supports MySQL 8's new authentication (non-legacy) method.
PS. The only trick in the tool side, not the DB side is when you are creating a MySQL 8 connection you might need to go to "Driver Properties" (later can be found in Edit Connection) and turn the value of allowPublicKeyRetrieval to true.
I needed this to connect to my MySQL container created using Docker. To have the IP of MySQL be visible to the outside, for any other application in your ecosystem (not just this tool), you should either create a new user in MySQL, or pass -e MYSQL_ROOT_HOST=% in the run-time or as an ENV.
Assuming you don't have a mysql configuration, echo the following to ~/.my.conf
[mysqld]
default-authentication-plugin=mysql_native_password
Sign into mysql with mysql -u root -p
Set the root user password with ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY '[PASSWORD]'; where [PASSWORD] is a password of your choosing.
Restart mysql with e.g. brew services restart mysql
Sequel Pro is officially dead and no longer supports newer MySql features. However, the good news is that it was replaced by Sequel Ace which is available on GitHub and App store. The app is free of charge and looks like official replacement for Sequel Pro as the post was made by one of the collaborators of Sequel Pro.
Ps. I decided to post this as an answer as others have not mentioned that there is now an up-to-date replacement for Sequel Pro
If you connect to MySQL via root#127.0.0.1, make sure that you reset its password too!
ALTER USER 'root'#'127.0.0.1' IDENTIFIED WITH mysql_native_password BY '[password]';
It's working for me. if you are getting this error :
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary
privileges, or try increasing the connection timeout (currently 10
seconds).
MySQL said: Authentication plugin 'caching_sha2_password' cannot be
loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2):
Plz try this solution
If anyone facing this issue and installed MySQL version > 8 through .dmg file; downloaded it from the official link. In that case please use this guideline. I am adding the same details below in case the link will not be available in the future.
This issue is because you're using the new Strong Password Encryption which is a new feature in MySQL 8, if you installed MySQL 8 using the .dmg file, you can go to System Preferences > MySQL and then click on Initialize Database type your password and select the second option Use Legacy Password Encryption.

MySQL Installer: Fails at creating user accounts

Currently trying to install and start a MySQL Server on my machine. I'm using the original, actual Installer/Wizard. After filling out all fields, setting a root passwords and also telling to create one user with the password on localhost, the application fails at the step "Creating user accounts".
The log says:
Attempting to Add New MySQL Users Authentication to host 'localhost'
for user 'root' using method 'mysql_native_password' failed with
message: Access denied for user 'root'#'localhost' (using password:
YES) Ended configuration step: Creating user accounts.
Interesting to note, I've done this on a testing device as well as on a fresh virtual machine. I've used different data and names actually, but with the same result >_< What could I be doing principally wrong?
Thanks in advance!
EDIT: Sort of solved... I re-downloaded the database alone and manually created users. Guess that's the better way when being about to learn SQL properly anyways.
That error blocks your installation - although your MySQL server is running - it keeps you from installing the samples and examples. However, if you ignore installing these samples and examples, you can start MySQL Workbench. Moreover, the root account will be available with the password you have set during the install procedure (using Windows). Just launch the Workbench.
I went back to the Accounts and Roles tab> "edit" on my user and my account said I needed a user name> reentered User name> save> next> rename MySQL> Execute== ran fine and finished install.
This was the easy way with all other updates for co-programs done already.
For anyone still having trouble, a simple solution for me was making sure my user names and passwords did not contain special characters such as \ > ~, and so on. Characters such as # and ! should work fine.

MySQL Password Not Working

EDIT: I had MySQL installed twice on my machine (XAMPP & on its own)
When I enter my password into MySQL Command Line Client, it rejects my password, gives 1 beep and closes the window. Can anyone provide me with a basic troubleshooting list of steps (from simple to progressively more technical) to regain entry into MySQL once and for all. Also, can anyone tell me what can cause my password to suddenly be rejected? I am also running XAMPP and the MySQL service is both installed and running. Thanks in advance.
I remember when I first got this problem some months ago, if I recall correctly, I solved it by starting the MySQL service from Windows XP's Administrative Tool (something I did stopped the MySQL service and to this day I don't know what it was).
Now the problem has started back again but this time, when I checked Services, the MySQL service was already 'started'.
Any assistance will be appreciated. Thanks
I think I figured out why my password was not working. I had two versions of MySQL installed on my machine (XAMPP and MySQL 5.1). So I deleted the MySQL 5.1 and it worked.
For me (and my similar problem),
--password = mypass
didn't work, but
--password="mypass"
did.
Is there an error message when it rejects your password? I wonder if perhaps you are using an outdated client and running into this issue: http://dev.mysql.com/doc/refman/5.1/en/old-client.html
If you set mySQL to not begin running on startup, then you need to start it prior to attempting to login. This can be done via the command line, via the task manager if you configured it as a windows service, etc.
For example, here is an explanation of starting the service using cmd
Starting MySQL from the Windows Command Line | MySQL
Do you have the password for the root account? If so, try this from the command line?
mysql --user=root --password=your password here
or
mysql --user=root --password=your password here --database=MySQL
A bit too late but - If you have numeric characters in your password and are using the numpad on your keyboard, ensure that the numlock is ON. For some weird reason if you have numlock off MySQL will still interpret a keystroke. This wasn't very obvious to me since my laptop doesn't have a num lock indicator light, thats HP for yah :)
How to Reset the Root Password | MySQL
This is the services solution that was mentioned. Use this if you can't remember your root password.
I'd like to add another successful solution to this problem. I reran the installer (the msi), chose the repair option and everything was fixed.
My password suddenly worked again, so I took the following steps to change it:
Using Windows Command Prompt, navigate to MySQL's bin directory
Type: mysqladmin -uroot -p password yourNewPassword
Press Enter. You will be prompted for your password, enter it
If no error messages/beeps happen, your password was successfully changed
Log in using MySQL Command Prompt with your new password
What I don't understand is that WHY all of a sudden my password started back to work after approximately 24 hours? I wish I know so I can avoid this in the future.

Connecting to MySQL from other machines

I have MySQL installed on a Windows 2003 server on our domain. I cannot connect to it from other machines on the domain. I open up the MySQL Administrator panel and try to change the server name from localhost to the machine name it does not recognize it. I have tried fully qualifying the name also. Any ideas what I need to change?
What sort of error, a total inability to connect? Windows Firewall is the first place I'd look, to make sure port 3306 is open.
have you double checked permissions on the databases using something like
grant all priviliges on 'database'.'*' to 'username'#'remote_machine_ip' identified by 'password';
Like Sukasa mentioned, also double check any firewalls you may have configured
You need to look in the my.cnf file and look for the bind-address setting and the skip-networking setting. You want the latter removed or commented out and the former to be the machine's IP address. Restart MySQL after you make changes.
A number of MySQL install packages defaulted to a local socket only install, which is helpful for security but considerably impairs network connectivity. :-)
I was trying to connect to the database using the default root userid. I created a new user and gave this user read permission to the needed tables.

My apps can't connect to mysql, can you suggest things to test?

I'm on a mac server. From my home directory, I can get to mysql on the command line. But apps I install (I've tried phpMyAdmin and then Wordpress) can't connect to mysql#localhost.
Suggestions on troubleshooting the problem?
Also, how can I tell what port mysql is running on?
Try specifying 127.0.0.1:3306 as the host and see if that works...
Edit from comments:
Use netstat -a to check which
port MySQL is listening on.
Check to make sure you have the mysql extension installed.
More information: http://us2.php.net/mysql
Make sure you have explicitly listed localhost when you granted permissions to the user. For example, if you have a database named blog which is accessed by a user named wordpress, you need to create the user with this:
grant all on blog.* to 'wordpress'#'localhost' identified by 'blahblah';
I believe that the mysql command-line utility uses Unix file sockets to connect, which bypasses any hostname or DNS restrictions.