MySQL Error - ALTER is not valid at this position - mysql

I am trying to execute the following query into MySQL Workbench 8.0.15:
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
I am receiving an error that states:
"ALTER" is not valid at this position for this server version, expecting : CACHE, CHECKSUM, COMMIT, DEALLOCATE, DO, EXECUTE, ...
What could I do to fix this error?

I had the same problem, I fix this error by creating a new connection in Mysql Workbench

Related

Cannot alter user in MySQL database

I have an issue with connection to MySQL database.
Internet says that error Unable to load authentication plugin 'caching_sha2_password' can be fixed with ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY '123';.
The issue is that this command doesn't work. ALTER USER 'root'#'%' IDENTIFIED WITH mysql_native_password BY '123'; also doesn't work.
First command affects 0 rows and has an error 1 factor authentication method does not match against authentication policy. Please refer ##authentication_policy system variable., second one returns an error Operation ALTER USER failed. Of course I'm replacing 123 with my real admin password.
I'm absolutely out of ideas, I hope I can get some clues why this command doesn't work.
Edit
I think the only solution is to uninstall newest MySQL version and install an older one that actually works. Topic closed.
You need to FLUSH PRIVILEGES after a user update command.

Setting Up Remote Access On mySQL Server Client Throwing Error 1064 (42000)

This is my first time trying to set up an SQL server. I used the installation client on mySQL and that all went fine, I can look at tables and edit them, but I want to be able to do it from the mySQL client on my Mac (The server is hosted on server running Windows Server 2008 r2).
I've tried using every variation of
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password';
going but it just throws the error 1064 (42000) near IDENTIFIED BY 'password';.
I've literally copied at least 10 variations of it and it says the same thing every time.
Is it something stupidly simple or have I not done it correctly?
remove the IDENTIFIED BY 'password' then grant password later with ALTER

MySQL database connection trouble when setting up TeamCity?

Unexpected exception MySQLSyntaxErrorException: SQL error when doing: Taking a connection from the data source
SQL exception: Unknown database 'teamcitydb'
I'm getting this error when I open the Web UI for the TeamCity server in firefox, and I'm not sure why it can't take a connection to this database. I followed all the steps in the installation procedure.
Any help or guidance would be appreciated!
It seems you have not create for database in the MySQL correctly.
According to the latest manual, you should run below command after connecting to the MySQL:
create database teamcitydb collate utf8_bin;
create user <user-name> identified by '<password>';
grant all privileges on <database-name>.* to <user-name>;
grant process on *.* to <user-name>;

Error 1142: SELECT and LOCK TABLE commands denied

I reinstalled the server running MySQL. I had created a backup of the database by using MySQL Workbench. Now I'm trying to import the dump in to the database trough the same program but I get the following error:
ERROR 1142 (42000) at line 656: SELECT,LOCK TABL command denied to user 'root'#'MIKKOS' for table 'events_waits_summary_by_thread_by_event_name'
I tought that root had full privileges. I ran the following but the same error appears with the previous query after executing this:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' WITH GRANT OPTION
It also appears when running locally (root#localhost).
What to do?
Check which databases MySQL Workbench included in the dumpfile. I believe it defaults to dumping everything, including DBs like user and performance_schema. Those are the problem, your grant tables are probably fine.
Remove the unneeded databases, especially performance_schema and MySQL will likely import the dumpfile without errors.
You need to repair internal table structure after reinstallation a newer MySQL server. To do so try:
REPAIR TABLE `events_waits_summary_by_thread_by_event_name`;
It would be better to drop database and restore it from full mysql database dump if you have one.

Adding user issue in MySQL 5.5

I have an install script that sets up a MySQL user + database + some tables. It worked fine in mysql 5.0, but we recently upgraded to Ubuntu 12.04, which ships with mysql 5.5. However in mysql 5.5 I am getting errors.
The problem seems to be related to adding users. I use a line like this to create a root user, which is later used to login with and set up the rest of the stuff:
INSERT INTO mysql.user VALUES('%','myrootuser','','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','','','','',0,0,0,0,'','');
flush privileges;
The command succeeds. However, when logging in with this new 'myrootuser', the user doesn't seem to have sufficient privileges:
jeroen#jeroen-ubuntu:~$ mysql -u myrootuser -e 'select * from mysql.user;'
ERROR 1142 (42000) at line 1: SELECT command denied to user ''#'localhost' for table 'user'
Also I noticed that I can login with non existing usernames, which might be obfuscating the real problem:
ubuntu#myserver:~$ mysql -u thisuserdoesnotexist
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 40
Server version: 5.5.22-0ubuntu1 (Ubuntu)
mysql>
Has there been some change in the MySQL authentication in 5.5 that I am not aware of?
For the user creation problem, try using phpMyAdmin to add it. PMA is better than SQL query!
For your login problem, delete the user * in the user list (use PMA). It will fix your problem! I got the same problem and I did that to fix it.