how to use mysql command in ssh? [closed] - mysql

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.

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.

mysql workbench not connecting with localhost on mac, Can't connect to MySQL server on '127.0.0.1 (49) [closed]

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 2 years ago.
Improve this question
I'm starting up with mysql on mac. I have installed Mysql and mysql workbench. My mysql server is running. When I try test connection with mysql workbench I get Can't connect to MySQL server on '127.0.0.1' (49). When I try to connect with terminal it works perfectly. In terminal I use the command mysql -u root -p then enter the password. I can't seem to figure this out, do I need to add something in my.cnf file ? Currently it says
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1
I can't find what (49) means in the error too. Thanks in advance. I'm using MacOS Mojave, mysql server version 8.0.17
EDIT : I reinstalled my MacOS, it started working. Guess some issue with some internal file.
Change the Connection Method menu to Local Socket/Pipe.
Leave the "Socket/Pipe Path" field empty to use the default socket. This is equivalent to omitting the -h option when using the mysql command line client.
See the documentation

Password after MySQL Community Server install from zip [closed]

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 9 years ago.
Improve this question
I have been installing the MySQL Community Server from ZIP Archive with the Inno Setup. I have used this install script (little modified) http://dark-it.blogspot.sk/2009/07/inno-setup-mysql-full-script.html, because I need one-click installation for my very simple application, which works with the MySQL database. My Installation to the Windows XP Professional was successful. Now the MySQL service is running correctly. But my problem is that I don´t know the username and the password for connect to this MySQL server. I have tried changed the username and the password in my.ini file but it wasn´t correct. And I tied blank password too. Can I somehow change the username and the password in this file? Or what is the default password after install? I need import my prepared database to one-click install too. I have located this database to /MyApplication/Data/Database_folder. In this directory are folders as test and performance_schema too. It is correct location?
Thanks for reply.
See the MySQL developer pages how to reset the root password.
Log on to your system as Administrator.
Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list and stop it.
If your server is not running as a service, you may need to use the Task Manager to force it to stop.
Create a text file containing the following statements. Replace the password with the password that you want to use.
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
Write the UPDATE and FLUSH statements each on a single line. The UPDATE statement resets the password for all root accounts, and the FLUSH statement tells the server to reload the grant tables into memory so that it notices the password change.
Save the file. For this example, the file will be named C:\mysql-init.txt.
Open a console window to get to the command prompt: From the Start menu, select Run, then enter cmd as the command to be run.
Start the MySQL server with the special --init-file option (notice that the backslash in the option value is doubled):
C:> C:\mysql\bin\mysqld-nt --init-file=C:\mysql-init.txt
If you installed MySQL to a location other than C:\mysql, adjust the command accordingly.
The server executes the contents of the file named by the --init-file option at startup, changing each root account password.
You can also add the --console option to the command if you want server output to appear in the console window rather than in a log file.
If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option:
C:> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe"
--defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini"
--init-file=C:\mysql-init.txt
The appropriate --defaults-file setting can be found using the Services Manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.
After the server has started successfully, delete C:\mysql-init.txt.
You should now be able to connect to the MySQL server as root using the new password. Stop the MySQL server, then restart it in normal mode again. If you run the server as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.
About importing you database I would prefer to use a SQL dump they are usually smaller and simple to install with something like this:
mysql -uroot -prootpwd dbname < dump.sql

MySQL Server does not start on Raspberry Pi [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 working with a Raspberry Pi running Debian Linux. I am trying to install MySQL Server and run it and here is what I have done:
# sudo apt-get install mysql-server mysql-client php5-mysql
No errors. Now I rebooted the system, then when starting up I get:
[FAIL] startpar: service(s) returned failure: mysql ... failed!
And I tried
# sudo service mysql start
mysql: unrecognized service
Lastly I tried
# /etc/init.d; mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I find that I have no folder named mysqld in /var/run. But I read that the sock file here shall be created the first time the server is created?
Do you have any suggestions?
Looks like your mysql server is not started. I usually run the stop command and then start it again:
mysqld stop
mysql.server start
Same error, and this works for me.
/etc/init.d; mysql
The usual way to start the mysql server would be
/etc/init.d/mysqld start
The reason it's failing should be written to the logs (usually /var/log/mysqld.log) - what do the logs say?
look into /var/log/mysql/error.log

MySQL server instance will never start. Mac OS Lion [closed]

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
I installed MySQL using the DMG file (http://dev.mysql.com/downloads/mysql/), and I installed the MySQL_etc.pkg, the MySQLStartUpItem.pkg and the MySQL.prefPane items.
Every time I try to start mysql from the command line I get the message:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)
Thanks to various posts on stackoverflow I discovered that this was because MySQL was not running. So I go to the MySQL pane in System Preferences and sure enough "The MySQL Server Instance is stopped". I click "Start MySQL Server" and I get the spinning beach ball for 2 minutes, then nothing happens. The MySQL Server Instance stays stopped.
If I restart my computer then I can go to the MySQL pane and it tells me that "The MySQL Server Instance is running". And sure enough mysql -v at the command line tells me my MySQL connection id, and that I have server version 5.6.10. But then if I leave mysql by typing exit the server instance stops, and I can only restart it by restarting my computer!
Any ideas? I haven't even been able to run MySQL for long enough to set passwords, let along create a database!
After an afternoon of false leads (I don't mean to sound ungrateful, all suggestions were followed up and I'm thankful for all advice), I uninstalled all traces of MySQL and reinstalled an older version, following the advice on this blog: http://soatechlab.blogspot.com/2011/01/completely-remove-mysql-on-mac-os-x.html
It appears to be working now.
Try:
prompt$ sudo mysqld -u root <secure password goes here!>
Note the sudo: MySQL wouldn't let me start up the server without root access to both the computer and MySQL itself. Also note that the program is mysqld, not mysql.
The command varies depending on how you installed MySQL. Try this first:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
If that fails:
cd /usr/local/mysql
sudo ./bin/mysqld_safe
(Enter your password, if necessary)
(Press Control-Z)
bg
I havent' tried this, but check this out if you are working with MAMP and php:-
http://twob.net/journal/fix-for-mamp-mysql/
Maybe even try a re-install and follow these docs:-
http://dev.mysql.com/doc/refman/5.6/en/macosx-installation.html
In addition, plenty of brainstorming on this page:-
https://stackoverflow.com/questions/4788381/getting-cant-connect-through-socket-tmp-mysql-when-installing-mysql-on-m