connecting to a mysql database remotely [closed] - mysql

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
What I would like to do is connect to a database that runs a website. Then copy the contents of that database to another database, on a different server. Can this be done?

It can be done and there are different ways to do it. I'll list 3 different ways
Run mysqldump -h<source host> | mysql -h<target host>. You'll have to read up on the mysqldump options to decide which you need to add and you probably need to put options for user, password and databases as well.
Copy all files that mysql uses and put them on the new host. As long as the new server is configured the same way it will work
Use Perconas xtrabackup. This is probably the best option if the database is large. The database can still run while the backup is being made. This option will create an exact copy of the database and that may or may not be wanted.
Generally if the database is small option 1 is easiest.

Yes, but it depends on how the database is set up.
Most databases that run behind a web server will not be accessible externally, for security reasons. Your best bet, assuming you have access to the server, is to login to the shell and dump the database. MySQL has the tool mysqldump to help with this. In a pinch:
mysqldump -u username -p schemaname > yourdatabasedump.sql
Alternatively, you could install PhpMyAdmin on your server (assuming PHP is enabled) and dump the database from there.
Importing is the opposite. Get shell access on the other server and do something like this... First, create your schema:
mysql -u someuser -p
> CREATE DATABASE schemaname;
> exit
Then import.
mysql -u someuser -p schemaname < yourdatabasedump.sql

Related

MySQL Workbench 8.0.28 export issue on MacOS 12.3 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 11 months ago.
Improve this question
Up until recently I was using MySQL Workbench 8.0.20 without any issues till I upgraded my MacOS to 12.3 after which the Workbench software itself stopped working. I then upgraded my Workbench version to 8.0.28 (latest version at the time of writing).
But after updating to the new version, I initially had issues connecting to my remote databases. I was getting the following error -
Got error: 2026: SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol when trying to connect
But I was able to solve that one by setting the 'Use SSL' option under the SSL tab for the connection to 'No'.
The next issue though is now I am not able to perform exports on the server using mysqldump. The Workbench software is trying to run the following command -
Running: /Applications/MySQLWorkbench.app/Contents/MacOS/mysqldump --defaults-file="/var/folders/fd/jt76prtj4z35dqd6y1y1_jcw0000gn/T/tmppuwxrtig/extraparams.cnf" --host=host.db.com --port=3306 --default-character-set=utf8 --user=logicspice --protocol=tcp --single-transaction=TRUE --column-statistics=0 --skip-triggers "database"
after which I'm getting a similar issue -
mysqldump: Got error: 2026: SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol when trying to connect
Is there an update I can do to a certain configuration file for either mysqldump or MySQL Workbench that will disable the use of SSL when trying to use mysqldump?
Your assistance would be much appreciated as this issue is causing delays in my development work. Thanks!
Summary of system -
Operating system - MacOS Monterey 12.3
Processor - 2.4 GHz 8-Core Intel Core i9
MySQL Workbench version - mysql-workbench-community-8.0.28-macos-x86_64.dmg
MySQL version - 5.6.10 (MySQL Community Server (GPL)) on AWS RDS
Exporting a MySQL or MariaDB database
To export the database, the mysqldump command is used from the console. Once the backup is done, the generated file can be easily moved. To start exporting the database you have to execute the following:
mysqldump -u username -p database_name > data-dump.sql
username : Refers to the name of the database user.
database_name : Must be replaced by the name of the database you want to export.
data-dump.sql : Is the file that will be generated with all the database information.
That command will not produce any visual output. So, to make sure that the SQL copy has been performed correctly, you can inspect the generated file to make sure that it is a SQL copy. To do this you can use the following statement:
head -n 5 data-dump.sql
That command should return something like this:
-- MySQL dump 10.13 Distrib 5.7.16, for Linux (x86_64)
--
-- Host: localhost Database: database_name
-- ------------------------------------------------------
-- Server version 5.7.16-0 ubuntu 0.16.04.1
It is also possible to export one or more tables instead of the entire database. To do this, you must indicate in the command the selection you want to make.
mysqldump -u username -p database_name table_name_1 table_name_2 table_name_3 > data-dump.sql
In this case, it is important to take special care with the relationships between the different records. When importing, only those tables that have been selected will be overwritten.
Importing a MySQL or MariaDB database
To import a MySQL or MariaDB dump, the first thing to do is to create the database into which the import will be done. To do this, if you do not have any database manager, you have to connect to the database server as "root" user.
mysql -u root –p
This will open the MySQL or MariaDB shell. You will then be able to create the database.
mysql> CREATE DATABASE new_database;
If everything went well, you will see something like this:
Query OK, 1 row affected (0.00 sec)
Once created, you have to exit this shell by pressing CTRL+D. Once you are in the normal command line, it will be time to launch the command that will perform the database import.
mysql -u username -p new_database < data-dump.sql
username : Is the name of the user with access to the database.
new_database : Is the name of the database where the import will be performed.
data-dump.sql : Is the name of the file containing all the sql statements to be imported.
If any errors occur during the import process, they will be displayed on the screen. As you can see, exporting and importing a MySQL or MariaDB database is a very simple process.
Note : All this is done with Ubuntu in a terminal but in MAC it is exactly the same .
Another solution : In case you still get that error I have found assuming you are using OpenSSL and not ysSSL.
Refer to the MySQL configuration variable ssl_cipher. ssl_cipher
Configure a list of ciphers including pseudo-encryption #SECLEVEL=1
For example :
ssl_cipher = "DHE-RSA-AES128-GCM-SHA256:AES128-SHA:#SECLEVEL=1"
If you need a more permissive but still secure encryption list.
"EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:ECDHE-RSA-AES128-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA128:DHE-RSA-AES128-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA128:ECDHE-RSA-AES128-SHA384:ECDHE-RSA-AES128-SHA128:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA384:AES128-GCM-SHA128:AES128-SHA128:AES128-SHA128:AES128-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4:#SECLEVEL=1"
taken from https://cipherlist.eu/ could do the job.

Is there any way to export a database using MYSQL Command Line Client? [duplicate]

This question already has answers here:
How to export a mysql database using Command Prompt?
(20 answers)
Closed 3 years ago.
Is there any way to export a MySQL database using MYSQL Command Line Client?
I have a database named as naukri_portal, which contains 3 tables. I am trying to export the database using MYSQL Command Line Client but it didn't work.
mysqldump -u root -p naukri_portal > naukri_portal.sql
you can use this command which will ask for a password and download your database into the current directory
mysqldump -u root -p database> dump.sql
if you are form windows use PowerShell administrator mode and if you are using Linux use Sudo command. Then run those query.
You can also follow below steps
Step -1 First download SQLyog https://sqlyog.jaleco.com/, then install it.
You will get something like
Now create a new connection for your localhost then connect to your remote database. You must remain connected to both servers together.
Step -2 Then right-click to your remote database you will get the following options.
step-3 Now click copy database to a different host then you will get another window like
step-4 Finally, select localhost and your database from the dropdown option. If you want structure and data check below option. Then click copy. The database will be copied. Due to my old version interface could be different but process will remain the same.

How to improve automatic MySQL Database Backup command (For linux users)

Am quite new in server management. Now am struggling to restore one database from whole MySql backup. Currently i have a mysql backup. Am using the following command for backup.
Mysqldump –u root –password={actual password for mysql} –h localhost –all-databases > /backup/mysql_backup.sql
gzip -9 /backup/mysql_backup.sql
I would like to improve this backup, because each back file should be more than 2.5 Gb and restoring is very difficult. If i can't restore from it, then what is the purpose of this backup? So i would like to improve this. Suppose i want to restore a particular database, then its very tedious to find that from this 3Gb file . So i would like to backup each database in a separate file. Any suggestion to improve the above command??

Mysql large table export size of 3GB [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I need to export a table of size 3GB to another database. Both are on different server.
When i tried to export using phpmyadmin tool, It leads to server error.
Also both database are on different servers. I need to export and import into other server.
Please advise.
Use mysqldump if that is a possibility, archive it and copy it afterwards to the new server.
If mysqldump is not accessible, phpMyAdmin has a feature to export it already archived ... try with that.
MySQL provides a tool exactly for this purpose:
commandline_of_your_choice#> mysqldump -uusername -p -hlocalhost DB_Name --single-transaction | mysql -uusername -p -hremotehost DB_Name
Simple as that :)

how to use mysql command in ssh? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am trying to import a sql file using command line: mysql -u USERNAME -p DATABASENAME < FILENAME.sql,
but I am not familiar with mysql command line.
I use ssh to connect to server, after connected, it shows: [tamp#need ~]$, i input mysql, it shows: -bash: mysql: command not found,
so what is the problem? what should I do?
It looks like mysql client is not installed on the server (or at least its binary is not in the right PATH); you should ask the system administrator to install it. If you're the administrator, well.. you should install it by your own, depending on which OS is installed on the host, you'd need a different procedure. For example, on debian based system you likely would run:
apt-get install mysql
This indicates that MySQL Client program are not installed in your machine.
You can install MySQL client by:
$ yum install mysql
OR
$ sudo apt-get install mysql-client
In fact, you have 2 options.
Either connect to your distant server using ssh -- then execute remotely mysql CLI on the server. That's what you have tried so far. But as other have already mentioned it, the mysql client doesn't seems to be present there.
The second option is to run mysql CLI on your local machine and connect it to your remote database server.
# Assuming your DB server has the DNS name "my-sql-server.home.local":
local-machine$ mysql -u user -h my-sql-server.home.local -p
# or
# Assuming you access your DB server by its IPv4 address "192.168.0.10"
local-machine$ mysql -u user -h 192.168.0.10 -p
Please note that, depending your mysql-server setup and your security policy the access may or may not be granted.