Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I'm trying to duplicate a MySQL (5.5.64-MariaDB) database on the same server by following this guide: Cloning a MySQL database on the same MySql instance
The accepted answer didn't work so I reviewed the docs over at MySQL and found that the mysqldump Options used --user and --password instead of the -u and -p flags on the linked post.
When I execute this:
mysqldump --user myUser --password myPassword dev_db | mysql -umyUser -pmyPassword staging_db
It firstly asks me to enter a password:
Enter password:
So I enter myPassword although unsure why as it's given in the arguments list.
Then it gives the following error:
mysqldump: Got error: 1049: "Unknown database 'myPassword'" when selecting the database
If I try entering the --username and --password without spaces:
mysqldump --usermyUser --passwordmyPassword dev_db | mysql -umyUser -pmyPassword staging_db
It errors
mysqldump: unknown option '--usermyUser'
The intention of this is to copy dev_db into a database called staging_db. Both of these databases exist on the same server. The username/password I'm using has full access to every database on the MySQL instance.
Why doesn't this work?
If I use:
$ mysql -umyUser -pmyPassword
It connects without any issue and gives me the MariaDB command prompt.
Server is running CentOS Linux release 7.7.1908 (Core)
Database version:
$ mysql -V
mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1
You can't have a space before the password.
--password=myPassword
or
-pmyPassword
When the --password option doesn't have a directly connected parameter, it means to prompt for the password.
Related
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.
Hey guys: I have one question access mysql using command line. I have no problem to access mysql based on this commend line "mysql --host=localhost --user=root --password="mypassword""; however, I have issue access mysql using the conventional way: "mysql root -p". I've tried many times to change root password. But I still only can access mysql using this commend line "mysql --host=localhost --user=root --password="mypassword"". Any comments are welcoming!
You have incorrect command as conventional way.
The error you mentioned in comment indicates that MySQL username is "ODBC" & you are not passing proper MySQL user in the command line. That is happening because you are using "mysql root -p".
Correct command is "mysql -u root -p". You missed the "-u " part.
I've got a MySQL database I'm using for a live project and I want to create a copy of it on the same server that I can use for development purposes. I have used MySQL dump to create a copy of the live database. I did this as follows:
mysqldump -u root -p mydatabase_live > mydatabase_dump.sql
I then logged into MySQL and created an empty database called mydatabase_test. I then try to copy the dump to the newly created database_test by logging back out of MySQL and doing the following:
mysql -u root -p database_test < mydatabase_dump.sql
This gives me the error message ERROR 1359 (HY000) at line 527: Trigger already exists.
When I log back into MySQL and examine the triggers on the database I've just took a dump of, I cannot see any triggers with duplicate names. I've tried repeating the above process in case there was some kind of error in the initial dump, but the problem repeats.
Can anyone explain why I'm getting this error message and how to solve this?
I'm using MySQL Ver 14.14 Distrib 5.7.25, for Linux
* NOTE ADDING DETAIL TO THE ANSWER ACCEPTED BELOW *
The MySQL dump file can be opened in a text editor. I used vim. The solution was to find the triggers and change the part of the trigger name which identifies it as belonging to the schema from which you took the dump, changing it to the schema you're aiming the dump at. In my case that meant changing mydatabase_live.my_table to mydatabase_test.my_table. Then logging into mysql, Dropping the test table and then recreating it, before logging out and performing the copy command again.
Triggers are stored on Information_Schema.Triggers table. Maybe that's why you cant duplicate them, maybe create a new one with a different name?
look here for more information
https://dev.mysql.com/doc/refman/8.0/en/faqs-triggers.html
Linux
mysqldump -u root -p mydatabase_live > mydatabase_dump.sql
mysqladmin create database_test
cat mydatabase_dump.sql | sed s/`mydatabase_live`/`database_test`/g | mysql -u root -p database_test
Windows
mysqldump -u root -p mydatabase_live > mydatabase_dump.sql
mysqladmin create database_test
type mydatabase_dump.sql | sed s/`mydatabase_live`/`database_test`/g | mysql -u root -p database_test
Notes
If you're in Windows, you'll need a windows version of sed (e.g. GnuWin32 sed)
I used a variation of several answers from a similar question at DBA Stack Exchange.
I'm using MySQL 5.7
mysqldump in 5.7 includes the database name when exporting triggers and views.
I put my password in an env var and passed it on the command line (i know, i'm bad, i get it). I mention it because I don't know what happens when you pipe data to the mysql executable and then it prompts for a password.
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 8 years ago.
Improve this question
Hi I want to insert sql database dump file in remote mysql server machine. i am using currently putty tool for doing this task. i have used lot of command but i am not able to do this. and i have also created database on that server but now i want insert database sql dump from server directory into mysql server.
I have also uploaded sql dump into home directory RHEL OS remote server machine.
i have used some command like -
mysql> use database_name;
mysql> mysql -u username -p database_name < /home/dump.sql;
mysql> mysql -u username -h host_ip -p database < /home/dump.sql;
mysql> mysql -u username -h host_ip -p database < /home/dump.sql;
mysql> mysql -u username -h host_ip -p dbpass -d database < /home/dump.sql;
mysql> mysql -u username -h host_ip database < /home/dump.sql;
mysql> plink mysql -u username -h host_ip -p database < /home/dump.sql;
and other command but i could not import sql dump into db server.
Please help me.
Thanks.
i think you are missing the password after -p syntax is
mysql -u username -p password db_name < /home/dump.sql
other possibility is that you are not providing proper directory or complete path of dump file
This question already has answers here:
how can I export mysql database using ssh?
(3 answers)
Closed 9 years ago.
I want to download mysql database from server using command prompt in windows.
I tried to use ssh to connect to the server.
But, it is not working. Is there any command to this?
Exporting MySQL Data
This example shows you how to export a database. It is a good idea to export your data often as a backup.
Using SSH, execute the following command:
mysqldump -p -u username database_name > dbname.sql
You will be prompted for a password, type in the password for the username and press Enter. Replace username, password and database_name with your MySQL username, password and database name.
The file dbname.sql now holds a backup of your database and is ready for download to your computer.
To export a single table from your database you would use the following command:
mysqldump -p --user=username database_name tableName > tableName.sql
Again you would need to replace the username, database and tableName with the correct information.
Once done the table specified would then be saved to your account as tableName.sql
Have a look Backup or Schema/Data Comparison tools in dbForge Studio for MySQL. Command line and conencting through secure SSH connections are supported.