mysql error when backing up a database that has views - mysql

When I back up a database (Structure and Data)
Options Checked:
CREATE DATABASE before copying
Add AUTO_INCREMENT value
it fails if the database has a view in it. I do not get this error backing up any other databases.
Here is Error message. I do not know what #1050 is in the MYSQL documentation:
SQL query: Edit Edit
CREATE TABLE vw_MediaOutlets-lk-ClientForContact (
fk_client_id INT( 11 ) , id INT( 11 ) , outlet_name TEXT,
outlet_subjects TEXT, email TEXT, circulation TEXT,
contact_title TEXT, city TEXT, state TEXT );
MySQL said: Documentation
1050 - Table 'vw_MediaOutlets-lk-ClientForContact' already exists
And then the result is an empty copied database.
I am using phpMyAdmin version 4.0.5
and mysql version 5.1.70-cll
on a shared hosted server
Any thoughts?
Thanks!

Related

I have an older .sql file (exported from 5.0.45) I am trying to import into a newer version of MySQL via phpMyAdmin. Receiving errors

Receiving the following error message:
Error
Static analysis:
1 errors were found during analysis.
This option conflicts with "AUTO_INCREMENT". (near "AUTO_INCREMENT" at position 692)
SQL query:
-- phpMyAdmin SQL Dump -- version 2.8.2.4 -- http://www.phpmyadmin.net -- -- Host: localhost:3306 -- Generation Time: Mar 23, 2020 at 03:58 PM -- Server version: 5.0.45 -- PHP Version: 5.2.3 -- -- Database: weir-jones -- -- -------------------------------------------------------- -- -- Table structure for table categories -- CREATE TABLE categories ( number int(11) NOT NULL auto_increment, section varchar(255) NOT NULL, parent_id varchar(10) NOT NULL, title varchar(200) NOT NULL, type varchar(255) NOT NULL, content text NOT NULL, display_order int(11) NOT NULL, PRIMARY KEY (number) ) ENGINE=MyISAM AUTO_INCREMENT=126 DEFAULT CHARSET=utf8 AUTO_INCREMENT=126
MySQL said: Documentation
1046 - No database selected
============================================
I have tried importing with all compatibility modes. No luck.
old database is gone, cannot export again.
Any help would be appreciated.
Brendan
If you ask for the 1046 No database selected then it is what it means. You exported a table from a database without the USE xxx.
So I would suggest try importing this within a database or add the USE clause on top on your SQL file.
Another thing:
If you ask a question on Stackoverflow make sure to read the "formatting rules". Wich means you can organzie your question.
It is actually quite hard to read what error you have. Use emphasis, code blocks and such things like:
CREATE table_blub
col1 CHAR(120) NOT NULL,
col2 INT(5)...
By this someone can better read what is code and what is the error and of course what is the actual question.
Eurobetics is correct, this is because the .sql file doesn't specify what database to work with. That's no problem, you can just create the database on your new server and import the file in to that. Since you're importing through phpMyAdmin, first use the "New" text in the left-hand navigation area to create a new database (you don't need to put any tables in it). Once the database is created, phpMyAdmin puts you in the database structure page. (If you happen to navigate away or are coming back after you've already created the database, just click the existing database in the navigation pane). Look at the tabs along the top row and use the "Import" tab there (or drag and drop your .sql file here).
Being inside that database page tells phpMyAdmin that you want to import to that database specifically, whereas if you're on the main home page, the Import button there isn't attached to any particular database, which leads to your error.
You could technically add the SQL commands to create the database and USE the database in to the .sql file, but in this case that doesn't seem like it's needed and would just be making more work for you.

MS SQL 2017 to MySql 8 migration with MySql Workbench

I've got a problem during migration. To migrate data between SQL Server 2017 and MySQL I use MySQL workbench (version 8.0.12). When script for new tables generation is completed I can find that there are many places where int is set to default value of '', for example:
CREATE TABLE IF NOT EXISTS `myname`.`Table1` (
`version` INT NOT NULL DEFAULT '',
...
)
And this, of course, is not working in next steps. Since I've got 'version' column in each table, is there any way that I can change this globally?
I know that I can go to each table and change it manually but it will be a lot of clicking...

Error while importing SQL database from local to server

I know this question has been asked before but I still couldn't get it fixed. I'm getting a #1046 error while importing my WP database from local to server. Here is what I get :
CREATE TABLE `wp_cntctfrm_field` (
`id` int(11) NOT NULL,
`name` char(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
MySQL a répondu (Translation: MYSQL responded) : Documentation
1046 - Aucune base n'a été sélectionnée(translation : no database was selected)
It's the first time I do it so I followed a tutorial but nothing seems to make it work.
You must select the target database you want to use to create/populate the database schema in.
You can select the target database at a global level for instance with Mysql Workbench in the left side, right hand click on the database you want to populate and select "Set as default schema".
You can also define the target database upon each SQL query.
For instance with your example, if the target database is named targetdb :
CREATE TABLE targetdb.wp_cntctfrm_field ( id int(11) NOT NULL, name char(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8
Please note that the target database must be created first with the appropriate CREATE DATABASE clause.
Hope this helps
You can use mysql -u <user> <DB_name> <<filename>
or add use <db_name>; at top of your dump file

Installation error creating table tuserremotesessions

Installing Mura on a brand new machine and local MySQL 5.7 database. Per the install instructions I browse to the Mura index.cfm file to complete the installation. I enter in the database and DSN info. After a few seconds I get an error message.
Error Executing Database Query.
Datasource: muracms
SQL: CREATE TABLE
IF NOT EXISTS tuserremotesessions ( userID char(35) default NULL,
authToken char(32) default NULL, data text, created datetime
default NULL, lastAccessed datetime default NULL, PRIMARY KEY
(userID) )
Code: 42000
Type: 42000
All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead
Refreshing browser page results in this error again. I can see that tables have already been created in the database. I have been unsuccessful at attempts to internet search for a solution.
Does anyone have an idea of what I can do to get past this error? I have successfully installed Mura on other servers before so I'm really stumped.
For those who run into this error, it is due to a change in MySql 5.7 from how MySql 5.6 worked. See http://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-3.html. Specifically
Columns in a PRIMARY KEY must be NOT NULL, but if declared explicitly
as NULL produced no error. Now an error occurs. For example, a
statement such as CREATE TABLE t (i INT NULL PRIMARY KEY) is rejected.
I edited the create table statements for several tables in {murahome}/requirements/mura/dbUpdates/5.2.0.cfm to remove the default NULL statement on two tables and then everything worked fine.

Problem using HSQLDB Transfer Tool with MySQL

I am trying to use the HSQLDB transfer tool to migrate a Database from MySQL. The tool is able to get the tables from the source MySQL database, however when I "start the transfer" I get the error,as follows and tables are not created in the target HSQLDB database.
org.hsqldb.util.DataAccessPointException: Unexpected token: PRIMARY in statement
[CREATE TABLE INST(INST_ID BIGINT NOT NULL ,INST_NAME VARCHAR NOT NULL ,INST_CO
DE VARCHAR NOT NULL ,PARENT BIGINT,OPEN_TIME TIMESTAMP,CLOSE_TIME TIMESTAMP,INST
_STATUS VARCHAR NOT NULL ,SCD_LICENSE CHAR(1) NOT NULL ,ADDRESS_LINE1 VARCHAR,AD
DRESS_LINE2 VARCHAR,CITY_ID BIGINT NOT NULL ,CASH_LIMIT BIGINT,DESCRIPTION VARCH
AR,INST_TYPE VARCHAR NOT NULL ,LAST_UPDATED_BY BIGINT NOT NULL ,LAST_UPDATED_DAT
E TIMESTAMP NOT NULL , CONSTRAINT PRIMARY]
Any idea how I could overcome this?
My main intention is to convert MySQL SQL into HSQLDB equivalenst, I guess there uses to be a tool to do this before MySQL workbench.
The documentation says that the Transfer Tool has not been developed for several years. I think you need to create a tool by your self, which translates a MYSQL Object DDL (Create Table, Create Procedure, etc) to a HSQL Object DDL (Which is basically SQL standards 92, 1999, 2003 and 2008).
I'm currently searching for one my self.
If you find one, please update this post?