I am using PHPMyAdmin that is a part of cPanel for a website of mine. My question is this: How can I specify a database such that I can create tables etc for the specified database.
My database name is canningi_db_person_cdtest
Currently, I am using the following statement in the Query textbox:
use canningi_db_person_cdtest
I get the following information:
Your SQL Query has been executed successfully
The webpage then refreshes, and if I try and create a table, I am getting the following error:
No database selected
What should I do?
You need a semicolon at the end of the database name. For example:
USE database;
SELECT * FROM table
https://dev.mysql.com/doc/refman/5.0/en/use.html
Trying to open this URL in your Web Browser :
http://localhost/phpmyadmin/
and then you can see all of database lists.
or if you using SQL command, try this :
use YOURDATABASENAME;
Related
I'm trying to copy a database.
From PHPMyAdmin, I've tried both the copy database functionality and the importing of an exported script. In both cases, I get this:
#1054 - Unknown column 'e.request_id`request_id' in 'group statement'
After the copy/import, since the error above relates to views, they will be missing in the new database.
In the old database, the view works. If I run show create view my_view_name, paste into the SQL tab of the new database, the view gets created without any problems.
Any ideas why manually running the create view statement works, but not through the copy/import process?
Edit #1
I just spotted the issue above.
I'm assuming the database copy and export reuse the same SQL generation process? They both complain here - note the extra request_id in the export script:
GROUP BY `sl`.`intake_type_id`, `e`.`request_id``request_id` ;
The show create view doesn't produce the same code:
group by `sl`.`intake_type_id`,`e`.`request_id`
In the old database, when editing the view, I don't see any issues either:
GROUP BY
`sl`.`intake_type_id`,
`e`.`request_id`
I ended up manually fixing the produced SQL file to remove the issue with the group by and other tidbits.
I started learning SQL but just in my first query, failed, i was doing exactly the same as the mentor explaining in the course but somehow his code worked mine not.
I also tried this query on PopSql it also did not work.
What is wrong here?
You need to select the database you are running this query on.
To do this via MySQL Workbench:
Click on the 'Schemas' tab highlighted below:
Then double click on the name of the database you are trying to run the query on, the database name will be bolded once selected.
You need to tell MySQL which database to use:
USE database_name;
before you create a table.
In case the database does not exist, you need to create it as:
CREATE DATABASE database_name;
followed by:
USE database_name;
I'm not that good at mysql but some of my tables has this line where I can edit and delete the row easy without writing any SQL? How can I make that row inside another table?
You can use any GUI editor like phpmyadmin or the tools which P.Salmon mentioned.
Using GUI editor, you can connect to the database using connection string and you can view tables and see the result which can edited and deleted.
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
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