I'm a Brand new User to MySQL DB, have installed the WAMPSERVER and I'm using MySQL through the MySQL console.
Query_1: Every time that I log in, it directly asks me for the password of root. However, i want to log in as a different user.
Query_2: If at all i do login as root, i want to switch user without closing the console.
How can I do this?
Thank you.
You can specify your username and password like this:
shell> mysql --user=user_name --password=your_password db_name
As far as I know, there is no way to change user after login without restarting the client.
I don't think its possible to switch users while in the console itself. You have to login with the different user instead.
Logging in use this command
mysql -u username -p
Then it will prompt for the password.
It is not possible to switch users in the MySQL console using WAMP. You must use SQL through the windows command line to switch users.
Steps (win 8):
1) Start
2) Type: 'command prompt'
3) Type: 'cd /'
4) Navigate to where WAMP bin is located, my location is: C:\wamp\bin\mysql\mysql5.6.17\bin by typing: 'CD wamp\bin\mysql\mysql5.6.17\bin'
5) run SQL under new user by typing 'mysql -u (username you want to use) -p (database you want to connect to)'
You will now be logged in as a new user.
If you attempt to login without specifying a user-name, MySQL will assume "root". In most cases you don't switch the user, but give a single user all the required rights;, for example to access multiple databases. If that is not possible for you, you can use two MySQL connections with two different users simultaneously.
The MySQL console provided in the wampserver admin panel, once a password is set, will prompt you for the root user's password before you can do anything. In order to log-in as a different user you need to log-in from the command-line. In order to this however, you'll need to add the file pathway to your installation of MySQL's bin folder to your user environment pathway so that your system will be able to access MySQL from the command line. To do this on windows open up file explorer, click on your C drive, open the wamp folder, open bin folder, open MySQL folder, open the MySQL folder with your installation version, open the bin folder you find there. In the file pathway bar of file explorer click on the folder icon to the left to generate the pathway to this bin folder, copy the pathway. Next open up control panel, in the search bar type the string environment variables, select edit user environment... you don't want to mess with the system environment, on the screen that appears choose the PATH variable- if it's not there then add it. Finally paste in the file pathway to MySQL's bin folder. Open up a command prompt and type mysql -u uswername -p hit return and then you'll be prompted for that user's password. Assuming of course you've made another user already.
As far as I know, once logged in as the root or any other user, the only way to switch is to exit mysql and then enter again as a different user.
Related
I am new to SQL and keep getting an error "Authentication plugin 'caching_sha2_password' cannot be loaded. The specific module can not be found" while connecting.
In your text editor of choice, open (or create) the /usr/local/etc/my.cnf file and add the following to the [mysqld] section of the file:
default-authentication-plugin=mysql_native_password
Open a terminal window, open an SSH session to your naked Mac Mini Server, and enter the following at the shell prompt:
mysql -u root -p
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'NEWPASSWORD';
Where NEWPASSWORD is the password you want to assign to the MySQL root user.
exit
Reboot your Mac.
Contents of this post is taken from farces.com
You have to "mysql_native_password" here to connect or else you have to configure "caching_sha2_password" plugin properly, as new MySQL comes with "caching_sha2_password" as below:
DROP USER 'your_user_name'#'localhost';
CREATE USER 'your_user_name'#'%' IDENTIFIED WITH mysql_native_password BY 'your_user_password';
GRANT ALL PRIVILEGES ON <db_name>.* TO 'your_user_name'#'%' identified by 'your_user_password';
The easy way around would be to reconfigure your MySQL server with a new authentication method. Just open the MySQL Installer community, and click on reconfigure next to the product MySQL Server. Keep clicking the 'Next' button until you see the authentication method window.
In this window ensure that the 'Use Legacy Authentication Method' option is selected. If not, select that option and proceed with the reconfiguration without changing any more settings. This will handle all errors that you may face when connecting to MySQL from Excel or R, etc.
In your specific case, it could be because your server is not running. To handle that, right-click on This PC on your computer and click on 'Manage'. Select 'Services and Applications' and then 'Services'. Scroll down the list that appears until you see your MySQL server. Click on the service and then click on start the service.
Before following all these instructions to downgrade your server security, make sure you have the latest version of MySQL Workbench! I kept getting that error when I tried running Workbench on an old computer. It had an older version of Workbench installed on it. I ran MySQL Installer and upgraded Workbench to the latest version and stopped getting that error.
I've just installed EasyPHP and in the MySQL section I created a new user called "foo" and checked the box to give it all privileges. When I click on the tab to manage the MySQL user accounts the user "foo" is there. But it shows foo's level of privileges only as "USAGE", and when I mouseover that word it says, "no privileges".
So I tried to update the privileges for foo. But when I try to edit them I get the error
"#1524 - Plugin '*E394918EB0645561038DD951D0CABA8042DDFE14' is not
loaded".
Interestingly, when I go back to the tab for user accounts and mouseover the "root" user it states
"Includes all privileges except GRANT"
Maybe this is why it can't grant "foo" any privileges?
Any idea how to give "foo" all privileges? I'd like to use that as my development account.
PS At the bottom of that page there is a message that says: "
Note: phpMyAdmin gets the users' privileges directly from MySQL's
privilege tables. The content of these tables may differ from the
privileges the server uses, if they have been changed manually."
Could this be a possible solution, and if so, could someone share a link that shows how to change the MySQL privilege table manually?
OK, after hours of searching around I'm getting much closer to a solution.
It turns out that there is an error in the EasyPHP installation package that is related to changes from earlier versions of MySQL. Here is the workaround:
(1) Open the file:
:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-binaries\dbserver\mysql5711x86x160717165359\my.ini
(2) Add this line at the end and then save the file:
show_compatibility_56 = on
(3) Restart the MySQL server from the EasyPHP dashboard.
Oh yes, I also ran the following upgrade from the MySQL command line:
mysql_upgrade -u root -p
This has cleared up some errors which showed up in other tabs that I didn't mention, such as not having permission to access the server status and not being able to get a list of the MySQL variables.
I still would like to solve the original problem but have spent too much time on this initial stage to work on it tonight. If anyone has info that please post.
I had the same issue. What I did to fix it was quite simple.
Exit EasyPhp.
Navigate to directory **\EasyPHP-Devserver-17\eds-binaries\dbserver\mysql5717x86xxx\data**
Find and remove the following files with ext .frm & .ibd
innodb_index_stats
innodb_table_stats
slave_master_info
slave_relay_log_info
slave_worker_info
After navigate to directory \EasyPHP-Devserver-17\eds-binaries\dbserver\mysql5717x86xxx\bin
Open command prompt and type
mysql_update -u root -p
<BLANK>
Afterwords you should see MySQL update, aswell as some of easyphp's files.
Exit mysql terminal, and start EasyPhp again.
Hope that helps!
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.
I recently installed mysql5.5 to my Windows 7 (x64) machine. The first problem was I couldn't enter the cmd client with mysql -u root -pmypass. The cmd opens, yields an error for like 0.5s and closes. Than I created another user account with all privileges, it worked and I created a database. But now I want to export that database from MySQL Workbench but I cannot see that in the "select a schema" option. I tried "new connection" and "new server instance" none worked.
Any suggestions?
Thanks in advance..
For the command line use WB too. In the list of connections you can right click for the context menu, which also offers to open a CLI window. In general, when you work with the CLI first open a normal CLI window (Start Menu -> Programs -> Accessories) and then try the mysql -u -p command. This way the CLI window won't close immediately and you can see what error message came out.
For WB: if you don't see a schema you know is there then probably the user you used to connect has no permissions to see it. So for tests try connecting as root and see if your schema is there. Import and Export of db objects (including entire schemas) is available in the admin section, not in the SQL IDE (where you found "Edit Table Data" etc.).
I'm having problems Creating Users in a Silverlight Business Application that uses the Local IIS Web Server.
If I use the Visual Studio Development Server I have no problems, but once I check "Use Local IIS Web Server" in the properties page and run the application, whenever I try to create a new user using "login->Register now" I get an "Unable to connect to SQL Server" error.
I found a similar problem as mine and the solution was to use aspnet_regsql in the command prompt.
If I have to use this tool, then I don't know how to use it:
aspnet_regsql.exe -S DBServerName -U DBLogin -P DBPassword -A all -d DBName
What should I enter in these parameters:
DBServerName: I guess it's ".\sqlexpress"
DBLogin and DBPassword: Kind of a login and password for the database?
DBName: If I'm not using any particular database, then what?
Please, what should I do here?
Navigate to the wizard(C:\Windows\Microsoft.NET\Framework[framework version]\aspnet_regsql) and launch it , you will be able to see a form appear and you can enter details here rather than using the command prompt.
Also within VS , from top menu select WEBSITE -> ASP.Net Configuration you should be able to see all your user and role details (you can tst the connectivity as this will pull of data based on your web.config/app.config settings)