Can't create mysql table in workbench - mysql

I have created a mysql database testing. A table 'table1' was created inside it.
But when i tried to read that table in using java it, gives an error like
'com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'testing.table1' doesn't exist'
I created table1 and inserted some data using insert tab and also clicked 'applychanges to data' button.But It doesn't work.enter image description here
There is no file table1.frm which is related to that table in the path 'C:\ProgramData\MySQL\MySQL Server 5.6\data\testing'.But default database 'sakila' and its tables are working perfectly.How to save my table??

Even though you have created tables in design view and saved those will not pushed to the DB. In order to apply them on DB you have to go to the menu "Database -> Forward Engineering" and generate the scripts and apply

Related

Modifying table entries from LibreOffice Base, possible?

I've successfully connected LibreOffice Base with MySQL data base server. I've tested if I modify my table from host (free hosting service on internet) then the changes are reflected when refreshing the table object in LO Base.
But my question is, can I modify DB table directly from LO Base? I guess that it's possible using sql queries from LO Base, but how? Please give me some insights or tutorials. Thanks.
The normal way to alter a table:
Tools -> SQL
Enter an ALTER TABLE command and press Execute button.
A way that works, even though it complains that no result set is returned:
Create a query in SQL view.
Enter ALTER TABLE command.
Click button in toolbar to mark it as Run SQL command directly. Or Edit -> Run SQL command directly.
Close the query and double-click to run it.
My guess is it could be done with a macro as well, similar to https://forum.openoffice.org/en/forum/viewtopic.php?f=5&t=75763 but using ALTER TABLE.
For more ideas see https://forum.openoffice.org/en/forum/viewtopic.php?f=61&t=37687.
EDIT:
Inserting new row data in a form is easier than altering the table. First, make sure this works:
Double-click on your table under Tables.
Insert -> Record, or enter data in the last new row.
If Insert -> Record is disabled, then you need to set up the table for editing. Make sure that your connection to the database allows editing. Also the table must have a primary key.
Once you can insert records in Table view, it's time to create the form:
Under Forms, Use Wizard to Create Form.
Select your table and press >> to include all fields.
Click Finish.
Now you should be able to open the form and enter data into the final new row.
More complete instructions with examples are at http://www.open-of-course.org/courses/mod/url/view.php?id=786.

Link Access Database with Mysql Server and Use Access as Frontend [Table Issue]

I was working on an Access Application that has already an access database (tables, queries etc ) and a front end. I was trying to link access existing database tables with mysql. So, what I have done so far is, I have successfully linked the access tables with mysql using ODBC. My understanding regarding linking access table with mysql db was that, by doing so, I would have the same 'old' access table linked with mysql, but I was wrong. Instead after linking I got a new table (fields same as old) that has links with mysql database.
http://i.imgur.com/mfSF5hR.png [See this link showing old 'access' and new 'linked' table]
For instance, I had an 'Actor' table in access db (before linking) and after it I have 2 tables. One is the old access 'Actor' table and other is the new linked table named 'Actor1'. So, if I do changes in my old access table, the table in mysql doesn't get change but when I do changes in my new linked table i.e 'Actor1' changes happen in mysql table too.
Here the problem is my front end form/queries are using my access table the old one, so is there any way to use new 'linked' table without changing in the front end ?
Thanks in advance.
You just need to rename your Linked MySQL table (rename the link in Access only) so that it matches perfectly the name you were using for that same table before in Access. This way you won't have to change your forms, queries, reports.
There is no magic that happens in Access between local tables and linked tables. It's still up to you to move your data, make sure the MySQL table is designed the way you want it, maintain the links, delete old Access tables, etc.

How to take MySQL database backup using MySQL Workbench?

How to take database backup using MySQL Workbench? Can we take backup in the following ways-
Backup file(.sql) contains both Create Table statements and Insert into Table Statements
Backup file(.sql) contains only Create Table Statements, not Insert into Table statements for all tables
Backup file(.sql) contains only Insert into Table Statements, not Create Table statements for all tables
For Workbench 6.0
Open MySql workbench.
To take database backup you need to create New Server Instance(If not available) within Server Administration.
Steps to Create New Server Instance:
Select New Server Instance option within Server Administrator.
Provide connection details.
After creating new server instance , it will be available in Server Administration list. Double click on Server instance you have created OR Click on Manage Import/Export option and Select Server Instance.
Now, From DATA EXPORT/RESTORE select DATA EXPORT option,Select Schema and Schema Object for backup.
You can take generate backup file in different way as given below-
Q.1) Backup file(.sql) contains both Create Table statements and Insert into Table Statements
ANS:
Select Start Export Option
Q.2) Backup file(.sql) contains only Create Table Statements, not Insert into Table statements for all tables
ANS:
Select Skip Table Data(no-data) option
Select Start Export Option
Q.3) Backup file(.sql) contains only Insert into Table Statements, not Create Table statements for all tables
ANS:
Select Advance Option Tab, Within Tables Panel- select no-create info-Do not write CREATE TABLE statement that re-create each dumped table option.
Select Start Export Option
For Workbench 6.3
Click on Management tab at left side in Navigator Panel
Click on Data Export Option
Select Schema
Select Tables
Select required option from dropdown below the tables list as per your requirement
Select Include Create schema checkbox
Click on Advance option
Select Complete insert checkbox in Inserts Panel
Start Export
For Workbench 8.0
Go to Server tab
Go to Database Export
This opens up something like this
Select the schema to export in the Tables to export
Click on Export to Self-Contained file
Check if Advanced Options... are exactly as you want the export
Click the button Start Export
Sever > Data Export
Select database, and start export
On ‘HOME’ page -- > select 'Manage Import / Export' under 'Server Administration'
A box comes up... choose which server holds the data you want to back up.
On the 'Export to Disk' tab, then select which databases you want to export.
If you want all the tables, select option ‘Export to self-contained file’, otherwise choose the other option for a selective restore
If you need advanced options, see other post, otherwise then click ‘Start Export’
In Window in new version you can export like this
The Data Export function in MySQL Workbench allows 2 of the 3 ways. There's a checkbox Skip Table Data (no-data) on the export page which allows to either dump with or without data. Just dumping the data without meta data is not supported.
In Workbench 6.3 it is supereasy:
On the "HOME"-view select one of the MySQL Connections: (localhost)
In the "Localhost" view click on "Server"--> "Data export"
In the "Data Export" view select the table(s) and whether you want to export only their structure, or structure and data,...
Click "Start Export"
In workbench 6.0
Connect to any of the database.
You will see two tabs.
1.Management
2. Schemas
By default Schemas tab is selected.
Select Management tab
then select Data Export .
You will get list of all databases.
select the desired database and and the file name and ther options you wish and start export.
You are done with backup.
I am using MySQL Workbench 8.0:
In Workbench 6.3 go to Server menu and then Choose Data Export. The dialog that comes up allows you to do all three things you want.

Rename mysql database? [duplicate]

This question already has answers here:
How do I rename a MySQL database (change schema name)?
(46 answers)
Closed 10 days ago.
How can I rename the MySQL database name using query?
I tried rename database via phpmyadmin and getting the following error,
SQL query:
RENAME DATABASE test TO test_bkp
MySQL said:
#1064 - 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 'DATABASE test To test_bkp' at line 1
In phpmyadmin you can just click on your database, then go to the Operations tab which lets you rename it.
It says here that:
This statement was added in MySQL 5.1.7 but was found to be dangerous
and was removed in MySQL 5.1.23. It was intended to enable upgrading
pre-5.1 databases to use the encoding implemented in 5.1 for mapping
database names to database directory names (see Section 9.2.3,
“Mapping of Identifiers to File Names”). However, use of this
statement could result in loss of database contents, which is why it
was removed. Do not use RENAME DATABASE in earlier versions in which
it is present.
You can import all data into a new database then delete the old one.
It is also possible to use the RENAME TABLE statement using same from/to table name but different from/to database. There are a few catches.
CREATE DATABASE `test_bkp`;
RENAME TABLE
`test`.`table1` TO `test_bkp`.`table1`,
`test`.`table2` TO `test_bkp`.`table2`,
`test`.`table3` TO `test_bkp`.`table3`;
It's been disabled by the developers. See http://dev.mysql.com/doc/refman/5.1/en/rename-database.html
Adding to this, I'd use a copy (then delete) rather than a rename. Have a look at Cloning a MySQL database on the same MySql instance
You can do this in MySQL < 5.1.23
with
RENAME {DATABASE | SCHEMA} db_name TO new_db_name;
In later versions have a look at
ALTER {DATABASE | SCHEMA} [db_name]
Ok, so if the rename option doesn't show, here a quick way of cloning a database using phpMyAdmin:
Open the database you want to copy
Click the Operations tab.
where it says "Copy database to:" type in the name of the new database.
Select "structure and data" to copy everything or "Structure only"
Check the box "CREATE DATABASE before copying" to create a new database.
Check the box "Add AUTO_INCREMENT value."
Click on the Go button to proceed.
NB before deleting the old database, make sure that passwords have also copied over.
in wamp server
click on databases
then choose your database
from header menu choose operations
make the new name
it will rename the database
but actually it create a new database copy all the data then drop the old data base
Export current database.
create a new database with a name you want.
import old database file on the new database.
Well, it's possible to rename your database but here's the logic behind the rename option.
1. Xampp creates a new database with the name
2. Xampp copies all table and data in it from the previous database
3. Xampp migrates data to the new database table and drops the previous database
Steps to rename Database
1. Click the Operations option in the nav pane
2. Find the ' Rename database to ' Spot, and input new name in the input field
3. Tick the ' Adjust privileges ' checkbox
4. Click go
I hope this works! :)
you can export your databse table, create a new one and import table to the new database!
also you can rename your data base using phpmyadmin by selecting your database and click on operations tab and rename your database!
the last and not recommended way is create a new databse and use this, but you may lost your data!
CREATE DATABASE new_db_name / DROP DATABASE old_db_name

How to show MYSQL statements that show how to create a particular table?

I've created and edited a couple of tables and don't want to recreate them from scratch if the database gets erased. What command allows me to "export" the field names and settings (NOT the content) as a ready to use MYSQL command that I can paste back on the MYSQL prompt?
SHOW CREATE TABLE tablename;
Reference: mySQL docs