MySQL 8: Alter definer of stored procedure - mysql

In versions of MySQL prior to 8, altering the definer of a stored procedure is possible by manipulating the mysql.proc table. This table was removed in 8 and replaced by the data dictionary. It looks like the definer can be modified using ALTER PROCEDURE, but for the life of me I cannot get the syntax specified to work.
mysql> alter procedure refresh_basic sql security definer=`foo`#`127.0.0.1`;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=`foo`#`127.0.0.1`' at line 1
mysql> alter procedure refresh_basic sql security definer='foo#127.0.0.1';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='foo#127.0.0.1'' at line 1
I also tried both of the above without using =, but got similar errors. How does one actually do this? Thanks!

Related

Create database in SQL and get an error but everything right

I try to install fleetspeak. Use Ubuntu 18.04.
First of all I run this
CREATE USER 'fleetspeak-user' IDENTIFIED BY 'fleetspeak-password';
Then I want to create database with this
CREATE DATABASE 'fleetspeak';
But has an error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near ''fleetspeak'' at line 1
Why I can get this?
Try the create database script without single quotes in dbname
CREATE DATABASE fleetspeak;

SQL Procedure error in printing statement

Delimiter $$;
create procedure greetings()
dbms_output.put_line('Hello'); $$
This gives the following error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.put_line('Hello')' at line 1
Any solutions?
MySQL does not provide dbms_output.put_line().
Instead of that you can simply try below code in your procedure.
SELECT 'Hello';

I am trying to insert into a table using "&" operator in MySql

I am using Server version: 5.6.26 MySQL Community Server (GPL).I am trying to insert into subodh table using & operator using following query
insert into subodh values(&date_of_birth,&name,&age,&qualification,&id);
but it is showing the following error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '&date
_of_birth,&name,&age,&qualification,&id)' at line 1
please help me.
Thanks

Cannot drop procedure with weird names in MySQL

In MySQL, I cannot drop procedure mobisys_mtly_db`cms_partner_add_or_edit because it has symbol `.
Detailed example in console
mysql> DROP PROCEDURE mobisys_mtly_db`cms_partner_add_or_edit;
`> `
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cms_partner_add_or_edit; ' at line 1
mysql> DROP PROCEDURE "mobisys_mtly_db\`cms_partner_add_or_edit";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"mobisys_mtly_db`cms_partner_add_or_edit"' at line 1
The following do not work:
DROP PROCEDURE mobisys_mtly_db`cms_partner_add_or_edit
DROP PROCEDURE mobisys_mtly_db\`cms_partner_add_or_edit
DROP PROCEDURE 'mobisys_mtly_db`cms_partner_add_or_edit'
DROP PROCEDURE 'mobisys_mtly_db\`cms_partner_add_or_edit'
DROP PROCEDURE "mobisys_mtly_db`cms_partner_add_or_edit"
DROP PROCEDURE "mobisys_mtly_db\`cms_partner_add_or_edit"
You should use this query -
DROP PROCEDURE `mobisys_mtly_db``cms_partner_add_or_edit`
Documentation page - Schema Object Names.

Run Sql file in MYSQL PHPMyadmin

I have written the SQL file with on excecuting it is throwing the error as
mysql> #"C:\Documents and Settings\Hemant\Desktop\create_tables.sql";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '#"C:\
Documents and Settings\Hemant\Desktop\create_tables.sql"' at line 1
on line 1 code is
CREATE DATABASE IF NOT EXISTS test;
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE test;
please let me know is i am missing something
Correct me if I'm wrong, but isn't there a table test by default when you setup PHPMyAdmin?
You have an extra semi column after test.
Try removing it and see if that fixes the issue.