My windows10 is not starting up but I have installed Ubuntu along with windows.
I have some mysql databases in my windows environment which I need backup so is there any way to open windows version of the databases in ubuntu so I can export that databases.
after handling JoSSte above comment you need to run these command in terminal
mysql -u user_name -p this command will ask for password
after successfull above command , you can check your database using below command
show databases;
if your database is there you can export database using below command
mysqldump -u your_db_user_name -p [database_which_need_to_export] > database_name.sql
this command will give you sql file then you can import it using command or in phpmyadmin
I've gotten a new laptop and after installing the newest version of xampp I cant log in to mysql as -u root.
I made sure that mysql is turned on in xampp.
Lines I've tried
cd\xampp\mysql\bin>mysql.exe -u root -p
cd\xampp\mysql\bin -u root -p
I've also tried starting mysql.exe directly and couldnt log in with similair commands.
The default setup of Xampp does not set a root password in mysql.
Try connecting without the -p. c:\xampp\mysql\bin\mysql.exe --user=root
The following is from the FAQ - https://www.apachefriends.org/faq_windows.html
Is XAMPP production ready?
Here a list of missing security in XAMPP:
The MySQL administrator (root) has no password.
I downloaded the mysql dmg file and went through the wizard to run. Done. I have also started mysql server under system preferences.
The purpose of me doing this is to work through the exercises of my SQL text book. The terminal commands are new to me but I think once I can actually get started, working through the exercises should be OK.
From researching the web the various blogs tell me to navigate to to the mysql folder in the terminal:
/usr/local/mysql
Fine. Then it gets a little less clear as nearly each article has a different set of instructions on how to proceed. I was fiddling with it yesterday and was prompted for a password - what is the default mysql password?
Could someone give me the steps to get up and running with mysql via the terminal?
(Updated for 2017)
When you installed MySQL it generated a password for the root user. You can connect using
/usr/local/mysql/bin/mysql -u root -p
and type in the generated password.
Previously, the root user in MySQL used to not have a password and could only connect from localhost. So you would connect using
/usr/local/mysql/bin/mysql -u root
open terminal and type
sudo sh -c 'echo /usr/local/mysql/bin > /etc/paths.d/mysql'
then close terminal and open a new terminal and type
mysql -u root -p
hit enter, and it will ask you for password
I have found this solution on https://teamtreehouse.com/community/says-mysql-command-not-found
now to set new password type
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
In the terminal, I typed:
/usr/local/mysql/bin/mysql -u root -p
I was then prompted to enter the temporary password that was given to me upon completion of the installation.
In MacOS, Mysql's executable file is located in /usr/local/mysql/bin/mysql and you can easily login to it with the following command:
/usr/local/mysql/bin/mysql -u USERNAME -p
But this is a very long command and very boring, so you can add mysql path to Os's Environment variable and access to it much easier.
For macOS Catalina and later
Starting with macOS Catalina, Mac devices use zsh as the default login shell and interactive shell and you have to update .zprofile file in your home directory.
echo 'export PATH="$PATH:/usr/local/mysql/bin"' >> ~/.zprofile
source ~/.zprofile
mysql -u USERNAME -p
For macOS Mojave and earlier
Although you can always switch to zsh, bash is the default shell in macOS Mojave and earlier and with bash you have to update .bash_profile file.
echo 'export PATH="$PATH:/usr/local/mysql/bin"' >> ~/.bash_profile
source ~/.bash_profile
mysql -u USERNAME -p
install homebrew via terminal
brew install mysql
This command works for me:
./mysql -u root -p
(PS: I'm working on mac through terminal)
In terminal
sudo sh -c 'echo /usr/local/mysql/bin > /etc/paths.d/mysql'
Close that and open new terminal
mysql -u root -p
Give your password
For mac OS Catalina :
/usr/local/mysql/bin/mysql -uroot -p
This will prompt you to enter password of mysql
You can simply type in Terminal
brew services start mysql
if you installed mysql via brew on mac
If you have your MySQL server up and running, then you just need a client to connect to it and start practicing. One is the mysql-client, which is a command-line tool, or you can use phpMyAdmin, which is a web-based tool.
This command works for me:
Command:
mysql --host=localhost -uroot -proot
try with either of the 2 below commands
/usr/local/mysql/bin/mysql -uroot
-- OR --
/usr/local/Cellar/mysql/<version>/bin/mysql -uroot
I'm trying to connect to mysql server command line from my windows prompt
I write the next line in cmd but i get an error.
cd C:\MYSQL\bin\
And then i execute
mysql.exe -u=root -p=admin
but i getting this error
ERROR 1045: <28000>: Access denied for user 'root'#'localhost' <using password:YES>
Thanks,
The cd in your question is invalid (quoting it here because you've removed it once, and it was there when this answer was posted):
cd CD:\MYSQL\bin\
You can't cd to CD:\ anything, because CD:\ isn't a valid directory in Windows. CD: would indicate a drive, except that drives are restricted to a single letter between A and Z.
If your \MYSQL\BIN is on drive C:, then your commands need to be:
C:\>cd \MYSQL\Bin
C:\MYSQL\Bin>mysql -u root -p admin
If you're not already on C: (which you'll know by looking at the prompt in the cmd window), or your MySQL folder is on another drive (for instance, D:), change to that drive too:
C:\> cd /d D:\MYSQL\Bin
D:\MYSQL\Bin>mysql -u root -p admin
The .exe after mysql is optional, since .exe is an executable extension on Windows. If you type mysql, Windows will automatically look for an executable file with that name and run it if it finds it.
Note that in both my examples of running mysql, there are no = signs. You should just use -p with no password, and wait to be prompted for it instead.
Use this :
mysql -u user_name -p then press_enter_key
then type password
i.e.
line-1 : mysql -u root -p
line-2 : admin
C:\Program Files\MySQL\MySQL Server 5.7\bin> mysql -u username -p
Then it will ask for the password.
Enter the password you set for the username during installation while adding db Users.
first type cmd then the windows command prompt will appear:
PATH C:\XAMPP\MYSQL\BIN;%PATH%;
mysql -u root -p
where:
-u is the user id
-p is the password, if you will not using a password just leave it blank.
You are logging in incorrectly; you should not include = in your login. So to log in, type:
mysql.exe -uroot -padmin
If that doesn't work, then you may not have your system configured. If so, then here's a good tutorial on getting started with the MySQL prompt:
http://breakdesign.blogspot.com/2007/11/getting-started-with-php-and-mysql-in_11.html
Start your MySQL server service from MySQL home directory. Your one is C:\MYSQL\bin\ so choose this directory in command line and type:
NET START MySQL
(After that you can open Windows Task Manager and verify in Processes tab is
mysqld.exe
process running. Maybe your problem is here.)
Type:
mysql -u
user
-p
[pressEnter]
Type your
password
[pressEnter]
or make a start.bat file:
add C:\MYSQL\bin\ to your PATH
write a start.bat file
My start.bat file has only two lines like below:
net start MySQL
mysql -u root -p
Good luck!
Please perform the following steps
First, open your command prompt with Administrator.
Go to MySQL installed directory and copy path and past on command prompt
like:- C:\Program Files\MySQL\MySQL Server 5.7\bin>
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -p [-u for username -p for password]
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -p
Enter password: **** [enter your password here]
To make it easier to invoke MySQL programs, you can add the path name of the MySQL bin directory to your Windows system PATH environment variable:
On the Windows desktop, right-click the My Computer icon, and select Properties.
Next select the Advanced tab from the System Properties menu that appears, and click the Environment Variables button.
Under System Variables, select Path, and then click the Edit button. The Edit System Variable dialogue should appear.
Place your cursor at the end of the text appearing in the space marked Variable Value. (Use the End key to ensure that your cursor is positioned at the very end of the text in this space.) Then enter the complete path name of your MySQL bin directory (for example, C:\Program Files\MySQL\MySQL Server 8.0\bin).
Open a different terminal and if you are using root as user run mysql -u root -p else use the a different username you created.
Simply to login mysql in windows, if you know your username and password.
Open your command prompt, for me the username is root and password is password
mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.11-log MySQL Community Server (GPL)
Hope it would help many one.
I have used following command to connect MySQL Server 8.0 in Windows command prompt.
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -u root -p my_db
Enter password: ****
or
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -u root -p my_db -h localhost
Enter password: ****
Here my_db is schema name.
First jump to the mysql bin directory. You have two ways to connect
1) mysql -u root -p1234
(without space for password flag)
2) mysql -u root -p
and enter the password when it is asking
If you're not on exact root of C:/ drive then first of all use cd../.. and then use query mysql -u username -p passsword
using the above lines you can access to mysql database.
Following commands will connect to any MySQL database
shell> mysql --host=localhost --user=myname --password=mypass mydb
or
shell> mysql -h localhost -u myname -pmypass mydb
Since it shows the password in plain text, you can type password later as prompted. So, the command will be as follows
shell> mysql --host=localhost --user=myname --password mydb
shell> mysql -h localhost -u myname -p mydb
Your have to go on mysql installed path is on drive C:, then your commands need to be:
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql.exe -u root -p
OR
C:\>cd \MYSQL\Bin
C:\MYSQL\Bin>mysql -u root -p
That will ask your MySql password over command prompt:
Enter password: ******
Put the password and you will get mysql dashboard.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4622
Server version: 5.7.14-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Go to your MySQL directory. As in my case its...
cd C:\Program Files\MySQL\MySQL Server 8.0\bin
mysql -uroot -p
root can be changed to your user whatever MySQL user you've set.
It will ask for your password. If you have a password, Type your password and press "Enter", If no password set just press Enter without typing. You will be connected to MySQL.
There is another way to directly connect to MySQL without every time, going to the directory and typing down the commands.
Create a .bat file.
First, add your path to MySQL. In my case it was,
cd C:\Program Files\MySQL\MySQL Server 8.0\bin
Then add these two lines
net start MySQL
mysql -u root -p
If you don't want to type password every time you can simply add password with -p e.g. -proot (in case root was the password) but that is not recommended.
Also, If you want to connect to other host than local (staging/production server). You can also add -h22.345.80.09 E.g. 22.345.80.09 is your server ip.
net start MySQL
mysql -u root -p -h22.345.80.0
Save the file. Just double click to open and connect directly to MySQL.
syntax to open mysql on window terminal as:
mysql -u -p
e.g.
mysql -uroot -proot
where:
-u followed by username of your database , which you provided at the time of installatin and
-p followed by password
Assumption: Assuming that mysql bin already included in path environment variable. if not included in path you can go till mysql bin folder and then run above command. if you want to know how to set path environment variable
If you don't want to go to bin folder of MySQL then another option is to put a shortcut of mysql.exe to your default path of command prompt (C:\Users\"your user name">) with the contents of:
mysql -u(username) -p(password)
I have a sql command I want to use to connect to my online database
mysql -h your_ddbb_server_ip -u your_user
I've installed MySQL installer 5.5 and ran the program.
After installing I tried running the command from both command prompt and a program called 'MySQL 5.5 Command Line Client'.
Neither program responded to the command.
How and where do I run this?
From a command prompt (cmd.exe)
be sure you have the mysql bin folder in the path (the installer prompts for that) so you can just type mysql.exe (or just mysql).
Otherwise you have to navigate to the MySql bin folder (in my case that's C:\Program Files\MySQL\MySQL Server 5.5\bin
cd "C:\Program Files\MySQL\MySQL Server 5.5\bin"
mysql -h your_ddbb_server_ip -u your_user
This command will launch an interactive shell. If you just want to execute a command you have to specify the -e argument
mysql -h your_ddbb_server_ip -u your_user-e "SHOW DATABASES"