Import Database to MySQL via WAMP server - mysql

I use SQL Server Management Studio to manage a database I've created, 'COMPANY', and am now attempting to write some PHP code to query the database.
However, I first need to have the database in MySQL before I can attempt to connect to it. I've downloaded WAMP server and have a .sql file containing a script for re-creating my database.
I'm unable to import my database into MySQL, though. I've tried
mysql> source /pathname/company.sql
But every time I execute the command, something flashes in the MySQL console window and then the window closes. Other times I get Error 22: File not found
How can I successfully execute my SQL file?

First create the db and
Try
mysql -u root -p dbName< '/pathname/company.sql'

Related

Can't Connect MYSQL server to VScode & General SQL installation issues

How do I install MySQL Workbench properly? Can't connect to the SQLTools extension in VSCode.I'm new to the database scene, and can't seem to grasp how to create a successful SQL server that I can use to manipulate data. But nothing I'm doing seems to work.
Should I use Gitbash to access the terminal? I tried using my password to make a new query but it wouldn't work on the workbench. I don't know how to start the SQL server in addition to not knowing how to properly change the profile for the Workbench from a previous account. A new developer, such as myself, would appreciate any insight!
So that's really simple just install the mysql community server installer using this link https://dev.mysql.com/downloads/mysql/
Make sure to select the server only in the setup during installation if you are going to be using VS code as the client to manipulate sql queries
Then once that is done copy the bin path location from the mysql file directory (which is usually in the program files on your \C: drive on your computer) to the environment variables on your computer so that you can access mysql from the command line
Once that is done you can initialise a database from the normal command line but first type mysql -u root -p to start mysql in the command line
Then download the sql tools extension on vs code and create the database that wish

How to copy table from a database on SERVER 1 to another database on SERVER 2 using phpMyAdmin?

I have a database named db_x on server X (running WHM) and another database named db_y on server Y. I connected to server X via SSH made some changes to the phpmyadmin configurations to allow it to connect to db_y via phpmyadmin on server X via cPanel. Now, I want to move all the tables of the db_x on server_X to another database(db_y) which is on different server(yy.yy.yy.yy) by using phpMyAdmin from server_X.
Is there any way to do so? Please help me.
Edit: The table is over 3 GB, so export/import won't work.
due to the size of your database you will not be able to succeed with phpmyadmin.
Try use the SSH.
Upload the database to the new server "old_database.sql".
Considering that the database already existis on the new server, use the command below:
# mysql new_database < old_database.sql
This command will import your sql file into the new database.
If you don't have the old_database.sql file, you can also obtain it with command in old server
# mysqldump mydatabase > old_database.sql
This command will generate an SQL file from your database.
Ther will be an option export in db_x export it and in db_y click import
and chose downloaded file wich was exported and click run.

Installing (minimal) MySQL Workbench to simply join data from two .csv files (connections???)

I previously used MySQL Workbench to do this, in an environment that was already set up.
How do I set up a minimal working environment to just create and join tables on my own computer? (Connections???)
More details:
I downloaded and installed MySQL Workbench, and I can't even run SELECT sysdate();. There's a red x next to it. If I try "CREATE DATABASE MY_DATABASE; there's a green check, but the execute button is grey.
Doing some reading I apparently need "connections." Reading about that, I apparently need to also install MySQL Database Server. Who knows what else.
So, again, the question is how do I set up a minimally working environment to just create tables from .csv files, join them with MySQL commands, and export the results to another .csv file? (I know the syntax of the command to import a .csv file, and how to join tables.)
Thanks.
Install MySQL WorkBench AND MySQL Server.
From the command line, in the directory where MySQL server is installed, execute "mysqld --initialize" (One time only.)
execute "mysqld" from the command line, after the initialization given in step 1, and after any reboots. (It runs in the background, and doesn't exit when you exit MySQL WorkBench. (It can optionally be installed as an automatically running Windows service during installation.)
Execute Database -> Connect to Database upon starting MySQL WorkBench (each time you start the application). The default local host connection works fine.
After doing File -> New Model and setting up table(s), do Database -> Forward Engineer. This will place your new database in the Schemas section on the home/main window.
Double click on the Schema you created (default name is mydb) and it changes to bold font. Now scripts you run from that main window will run against the database you created.

How do I export a MySQL database from PHPMyAdmin and import it to SQLite?

I would like to export a database from PHPMyAdmin (or MySQl Workbench) and import it to a SQLite database so that I can do local editing and testing without screwing up the live version. I am very new to SQL, so all of the export options, etc, are rather dense to me at this point. I have tried using the default export settings PHPMyAdmin with the command
sqlite3 test_db.db < maindb.sql
as well as
sqlite3--> .read maindb.sql
But these throw a bunch of syntax errors and 'no such table' errors.
I have also tried the oft-cited script script found here, but when I try to run this using an export from MySQL Workbench, using the command:
943776/mysql2sqlite.sh maindb.sql | sqlite3 test_db.sqlite
I get the following error:
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysql.sock' (2) when trying to connect
Am I not configuring the exports correctly?
Please see that the referenced script connects to the database server itself. It does not expect a dump!
./mysql2sqlite -h example.com -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
This is the way the script should be executed. With host, username, passwort and the mysql database you would like to dump.
Since database dumps and DBMS features can be severely different between different DBMS (like MySQL and sqlite3), I would recommend to install a local MySQL server instead of using sqlite3. What advantage have you achieved when you make changes to sqlite3, which you cannot apply to the MySQL production database without changes?
An alternative solution is to export an sql dump of your database and then import it back into phpLiteAdmin. From there you can manage your sqlite database inside your browser. When you want to export it, just open the folder where the database is stored and copy the database file.
This solution does not require messing around with scripts, and it's especially handy if you're on a Mac and you're using MAMP, since phpLiteAdmin comes preinstalled with it.

cannot upload large .sql database file to newly installed mysql using mysqldump in windows 7 <new mysql user>

I've checked through tons of forums and cannot seem to fix this. I need to upload a large database dump file (.sql) to mysql so that I can begin using the database as a key component of a website build project. I've tried various methods and I've been unsuccessful with all. First I tried to upload via phpmyadmin with no avail (it seems the file is too big). So I downloaded mysql and have begun learning cmd prompts (before I did that I tried to import from disk and from Dump Project Folder in MySQL Workbench - I received errors no matter where I put the file, e.g. in the MySQL Server 5.5\bin folder or the folder where I originally had it C:\Program Files\my project\test.sql - errors included "ERROR 1046 (3D000) at line 22: No database selected"). Regarding command prompts, I've set up MySQL in environment variables path and when I enter:
mysql> source c:/program files/mysql/mysql server 5.5/bin/test.sql
The cmd freaks out and starts producing lines and lines of ERROR 1046 (...) then after a few minutes of producing lines it says Query OK, 0 rows affected <0.00 sec> for about 10 lines then returns to the "mysql>" prompt. I thought the fact that my file began with "g" may have been the problem so I changed it to start with "t" and it did the same thing. That seems to be the closest I've managed to come to accessing this file. I've been trying for months now. I really need to get into this file and I'm at a loss. Can someone please help??
You need to select a database, as your error says. I have no clue what your .sql file says, and why there is no "use DATABASE" string in there, but
Check if you have made a database (show databases;)
If not made, make a database. (http://dev.mysql.com/doc/refman/5.0/en/create-database.html )
use the database with use databasename
load your script.
Login to MySQL and create a new database, say "mydatabase". Then run the following query on the command prompt (not inside MySQL)
mysql -u root -p mydatabase < my_large_db_dump.sql